Home › Forums › WinForms controls › Xceed Grid for WinForms › checkbox event
-
AuthorPosts
-
#16684 |
Hi,
I have a boolean column with checkboxs. When the user clicks on a checkbox I want to raise a event, which I use to build a string. If the user unchecks a checkbox I was to raise a event, once again to build a string.
The trouble I am having is raising a click and unclick event for the checkboxs.
Any ideas?
vb.net please
Thanks in advance.
Troy.Imported from legacy forums. Posted by troy@querytool.com (had 724 views)
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 CheckBoxEditor_ActivatingControl
AddHandler GridControl1.Columns( 0 ).CellEditorManager.DeactivatingControl, AddressOf CheckBoxEditor_DeactivatingControlEnd 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 checkBox.CheckedChanged, AddressOf checkBox_CheckedChangedEnd 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 checkBox.CheckedChanged, AddressOf checkBox_CheckedChanged
End SubPrivate sub checkBox_CheckedChanged(ByVal sender As System.Object, ByVal e As EventArgs )
System.Diagnostics.Debug.WriteLine( CType( sender, WinCheckBox ).CheckState.ToString() )
End SubImported from legacy forums. Posted by André (had 410 views)
Thanks works well.
Just a few typos for others looking at this code:
AddHandler xg.Columns(“col4”).CellEditorManager.ActivatingControl, AddressOf CheckBoxEditor_ActivatingControl
AddHandler xg.Columns(“col4”).CellEditorManager.DeactivatingControl, AddressOf CheckBoxEditor_DeactivatingControl
End SubPrivate Sub CheckBoxEditor_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_CheckedChangedEnd Sub
Private Sub CheckBoxEditor_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_CheckedChangedEnd Sub
Private Sub checkBox_CheckedChanged(ByVal sender As System.Object, ByVal e As EventArgs)
MessageBox.Show(CType(sender, WinCheckBox).CheckState.ToString())
‘ System.Diagnostics.Debug.WriteLine(CType(sender, WinCheckBox).CheckState.ToString())End Sub
Imported from legacy forums. Posted by troy@querytool.com (had 952 views)
-
AuthorPosts
- You must be logged in to reply to this topic.