Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Hi,
I have a datagridview with a checkbox column. I want to capture the value of checkbox immediately when user changes it by clicking. I tried several events (CellValueChanged, CellClicked,CurrentCellDirtyStateChanged etc.) but nothing worked.
My code is
If dgvIDsTBC.CurrentRow.Cells(2).Value = True Then
      MsgBox("True")
End If
Please advise what event to use for this.
Thanks
Furqan
Posted 15-Mar-11 23:41pm
Edited 16-Mar-11 0:55am
Prerak Patel140.2K
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Use CellContentClick
 
[Edit]
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    MsgBox(DirectCast(sender, Forms.DataGridView).Rows(e.RowIndex).Cells(e.ColumnIndex).EditedFormattedValue)
  End Sub
  Permalink  
v2
Comments
Amit Kumar Tiwari at 16-Mar-11 6:18am
   
Perfect answer, +5
Prerak Patel at 16-Mar-11 6:20am
   
Thanks
kfsehgal at 16-Mar-11 13:08pm
   
CellContentClick does not work.
Prerak Patel at 16-Mar-11 13:17pm
   
That is not enough, show how you did it. It would definitely work.
kfsehgal at 16-Mar-11 13:26pm
   
Actually the above given method works, but partially in the way I want.
I gave this code
 
MsgBox("Clicked")
MsgBox(DataGridView1.CurrentRow.Cells(2).Value)
 
While I want to capture the current value of checkbox, it True or False but in either cases, it show a blank box.
Prerak Patel at 16-Mar-11 23:38pm
   
I have updated the answer, you can check that now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 686
1 OriginalGriff 345
2 CPallini 200
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,028
2 CPallini 4,700
3 George Jonsson 3,142
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 16 Mar 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100