Edit Checkbox (in DataGrid) when enter cell?

B

Bruce D

I have added a checkbox to my datagrid (programatically with
'DataGridBoolColumn'). It works great...except one thing...when I first
click on the checkbox in my grid it doesn't do anything...it's like its only
getting focus (it's not grey). After the initial click, I can toggle the
checkmark. The one thing I notice is the record pointer in the datagrid.
On the first click (into the cell), it's still an arrow. But when I start
to toggle the checkmark, I noticed it's a pencil.

Any advice?

Sorry, I'm a bit new to VB.NET.

-bruce duncan
 
B

Bruce D

Figured it out...with thanks to http://64.78.52.104/FAQ/WinForms/default.asp

Private Sub DataGrid1_MouseUp(ByVal sender As Object, ByVal e As
MouseEventArgs) Handles DataGrid1.MouseUp
Dim intCheckBoxCol() As Integer = {4, 5, 6}
Dim hti As DataGrid.HitTestInfo = Me.DataGrid1.HitTest(e.X, e.Y)
Try
For i As Integer = 0 To 2
If hti.Type = DataGrid.HitTestType.Cell AndAlso hti.Column =
intCheckBoxCol(i) Then
Me.DataGrid1(hti.Row, hti.Column) = Not
CBool(Me.DataGrid1(hti.Row, hti.Column))
End If
Next
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub


-bruce
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top