Using vb.net and DataGridView in Winforms. What even should I use to know when the checkbox has changed?
A:
Is
DataGridViewCheckBoxCell.EditingCellValueChangedwhat you want?
John at CashCommons
2009-12-24 03:34:28
what is DataGridViewCheckBoxCell? Types as such gets an error.
bochur1
2009-12-24 03:48:54
You have a DataGridViewCheckBoxColumn right? They have DataGridViewCheckBoxCell as the cell type: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcell.aspx
John at CashCommons
2009-12-24 08:26:11
A:
You need to set up an event handler to do work when a cell's contents have been changed. Then, based on the arguments passed, you can see if the checkbox was checked or unchecked, and do work accordingly.
Private Sub myDataGrid_CellContentClick(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) _
Handles myDataGrid.CellContentClick
If myDataGrid.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "True" Then
'Checked condition'
Else
'Unchecked Condition'
End If
End Sub
Hope that helps!
David Hague
2009-12-24 13:17:16
A:
Did you mean how do you know when the DataGridView changes? A DataGridView is not a checkbox.
Add an event handler to handle a CellValueChanged event.
Private Sub MySubName(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
End Sub
(replace MySubName with whatever you want, and DataGridView1 with the name of your DataGridView).
Fill in the body of the Sub to handle the event.
Larry Watanabe
2009-12-24 13:26:53