Home Forums WinForms controls Xceed Grid for WinForms WinCheckbox Reply To: WinCheckbox

User (Old forums)
Member
Post count: 23064

Actually, my example was not quite right.  Sorry for the confusion.  The event handler must be associated to the Editor, not to the cell.

You need to subscribe to the CheckBox events through 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 CellEditorManager_ActivatingControl

    AddHandler GridControl1.Columns( 0 ).CellEditorManager.DeactivatingControl, AddressOf CellEditorManager_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.WinCheckBox = CType( e.Control, Xceed.Editors.WinCheckBox )

    AddHandler editor.CheckedChanged, AddressOf checkBox_CheckedChanged

 

  End Sub

 

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

   

    Dim editor as Xceed.Editors.WinCheckBox = CType( e.Control, Xceed.Editors.WinCheckBox )

    ‘this needs to be done, if not, subscriptions will pill up every time the editor is activated

    RemoveHandler editor.CheckedChanged, AddressOf checkBox_CheckedChanged

 

  End Sub

 

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

 

    System.Diagnostics.Debug.WriteLine( CType( sender, WinCheckBox ).CheckState.ToString() )

   

  End Sub

 

Imported from legacy forums. Posted by Ghislain (had 1731 views)