By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,083 Members | 2,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,083 IT Pros & Developers. It's quick & easy.

VB.NET 2005 DataGridView Checkbox - Check Event need to know check status

P: 6
VB.NET 2005 DataGridView Checkbox - Check Event need to know check status

I would like to use the DataGridView Checkbox like a normal checkbox.

When someone clicks on it I would expect that I could get a checked or changed event and be able to test if the box was checked or unchecked.

For a normal checkbox. When it is checked you can test chk.checked and it is the current visible stated. Someone checks it and your test for chk.checked is true. If it was unchecked then chk.checked is false.

In the DGV this does not seem to be the case.
You check the checkbox and there is some data in the other cells in that row and the value is nothing.
Private Sub grdLogon_CellContentClick
If grdLogon.Item(2, e.RowIndex).Value Is Nothing Then
'>>> It comes here
End If

If grdLogon.Item(2, e.RowIndex).Value Then
' Expeced checked but comes here when it was all the time
end if

The test grdLogon.Item(2, e.RowIndex).Value seems to work fine when used in other places (not a event from grdLogon.

I do not understand when this object has a value and when it is nothing nor how to make it work like a normal CheckBox.

Thanks & Happy Holidays!
Dec 21 '07 #1
Share this Question
Share on Google+
1 Reply

P: 11
For this first we have to get the row of the grid in object

like this

for (int i = 0; i <= bl_ctrlgridviewresult.Rows.Count-1; i++)
GridViewRow bl_gridviewrow;
bl_gridviewrow = bl_ctrlgridviewresult.Rows[i];
CheckBox cb = (CheckBox)bl_gridviewrow.FindControl("chkDelete");
if (cb.Checked)

DataRow dra = ds1.Rows[i - bl_incnt];
bl_incnt = bl_incnt + 1;


chkDelete is the check box name which we are mentioned in itemtemplate.

try the above code.
Dec 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.