Home Forums WinForms controls Xceed Grid for WinForms Updating a Cells upon a previous cells change Reply To: Updating a Cells upon a previous cells change

User (Old forums)
Member
Post count: 23064

What you need is to subscribe to events on the ComboBox editor as such, so that when the SelectedValue changes in the first ComboBox, you can prepare the binding for the second one, and then bind it properly when it actually get activated.

In order to subscribe to ComboBox events, you need to first subscribe to the ActivatingControl event of the CellEditorManager.  This is necessary because the editor is actually initialized only when the cell receives focus, and enters the edit mode.

e.g.:

//at Form_Load

  Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    AddHandler GridControl1.Columns( 0 ).CellEditorManager.ActivatingControl, AddressOf CheckBoxEditor_ActivatingControl
    AddHandler GridControl1.Columns( 0 ).CellEditorManager.DeactivatingControl, AddressOf CheckBoxEditor_DeactivatingControl

  End Sub

//Event handlers

  Private Sub CellEditorManager_ActivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )

    Dim editor as Xceed.Editors.WinComboBox = CType( e.Control, Xceed.Editors.WinComboBox )
    AddHandler editor.SelectedIndexChanged, AddressOf editor_SelectedIndexChanged

  End Sub

  Private Sub CellEditorManager_DeactivatingControl( ByVal sender As Object, ByVal e As Xceed.Grid.Editors.CellEditorEventArgs )
   
    Dim editor as Xceed.Editors.WinComboBox = CType( e.Control, Xceed.Editors.WinComboBox )
    ‘this needs to be done, if not, subscriptions will pill up every time the editor is activated
    RemoveHandler editor.SelectedIndexChanged, AddressOf editor_SelectedIndexChanged
 
  End Sub

  Private sub editor_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As EventArgs )

    Dim index As String = “index ” + CType( sender, WinComboBox ).SelectedIndex.ToString()
    System.Diagnostics.Debug.WriteLine( index )
    
  End Sub

Imported from legacy forums. Posted by André (had 380 views)