Home Forums WinForms controls Xceed Grid for WinForms Unbound column combo box selected index issue

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15592 |

    I have an application that contains an unbound data column of an assortment of data types (boolean, integer, string, etc) one row of which contains a drop down list (combo box control). I’m able to bind and display the data correctly however when I select an item, immediately after I change focus to another item on the grid, the value of the drop down changes to a seemingly random entry in it’s list. I’m enclosing the source code for this item, any help would be appreciated.

    Dim cbCtrl As New Xceed.Grid.Editors.ComboBoxEditor
    Dim cbList As New Xceed.Editors.WinComboBox

    Dim count As Integer
    cbCtrl.TemplateControl.AllowDropDown = True
    cbCtrl.TemplateControl.DropDownControl.Visible = True
    cbCtrl.Columns.Add(New ColumnInfo(“DepartmentID”, GetType(String), 50, 0, ColumnSortDirection.Descending))
    cbCtrl.Columns.Add(New ColumnInfo(“value”, GetType(Boolean), 15, 0, ColumnSortDirection.None))
    cbCtrl.Columns.Add(New ColumnInfo(“DepartmentDesc”, GetType(String), 50, 0, ColumnSortDirection.None))

    cbCtrl.TemplateControl.AllowFreeText = False
    cbCtrl.TemplateControl.DropDownControl.Name = “department_elements”
    cbCtrl.TemplateControl.Name = “departments”

    AddHandler cbCtrl.ActivatingControl, AddressOf Me._ActivatingComboBoxControl
    AddHandler cbCtrl.DeactivatingControl, AddressOf Me._DeactivatingComboBoxControl

    ‘Data binding segment omitted

    cbCtrl.Columns(“DepartmentDesc”).Width = 20
    cbCtrl.Columns(“DepartmentID”).Visible = False
    cbCtrl.Columns(“value”).Visible = False
    cbCtrl.DisplayFormat = “%DepartmentDesc%”

    Private Sub _ActivatingComboBoxControl(ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs)
    Dim wcb As Xceed.Editors.WinComboBox = CType(e.Control, Xceed.Editors.WinComboBox)
    Dim dc As Xceed.Grid.DataCell = CType(e.Cell, Xceed.Grid.DataCell)
    Dim dr As Xceed.Grid.DataRow
    dc.Capture = True
    AddHandler dc.ValueChanged, AddressOf Me.ddc_DataChanged
    AddHandler wcb.SelectedIndexChanged, AddressOf Me.cbSelectedIndexChangedHandler
    End Sub

    Private Sub _DeactivatingComboBoxControl(ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs)
    Dim wcb As Xceed.Editors.WinComboBox = CType(e.Control, Xceed.Editors.WinComboBox)
    RemoveHandler wcb.SelectedIndexChanged, AddressOf Me.cbSelectedIndexChangedHandler
    End Sub

    Private Sub cbSelectedIndexChangedHandler(ByVal sender As Object, ByVal e As EventArgs)
    Dim wcb As Xceed.Editors.WinComboBox = sender
    Dim val As Boolean
    Dim str As String
    Dim id As String
    Dim iIndex As Integer = wcb.SelectedIndex
    Dim xgc As Xceed.Grid.GridControl = CType(wcb.Parent.Parent, Xceed.Grid.GridControl)
    Dim cdr As Xceed.Grid.DataRow = xgc.CurrentRow
    Dim aid As String = cdr.Cells(“AttributeID”).Value
    Dim atype As String = cdr.Cells(“AttributeValType”).Value
    Dim strIndex As String = xgc.CurrentGrid.ParentDataRow.Cells(“Index”).Value

    Select Case wcb.Name
    Case “departments”
    id = wcb.Items(iIndex).Item(“DepartmentID”)
    Case Else
    End Select
    RemoveHandler wcb.SelectedIndexChanged, AddressOf Me.cbSelectedIndexChangedHandler
    wcb.SelectedIndex = iIndex
    ‘pnlDetailGrid is just a VB Panel used to house the grid control.
    Me.pnlDetailGrid.Focus()
    End Sub

    Imported from legacy forums. Posted by Richard.White (had 2063 views)

    User (Old forums)
    Member
    Post count: 23064

    Richard resolved his issue, I was in contact with him directly through our support inbox. If you have a chance Richard, can you share with us what you did to resolve your issue.

    Imported from legacy forums. Posted by Matt (had 2932 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.