-
May 13th, 2013, 06:12 AM
#1
Datagridview Checkbox
Hi all,
I have the following codes:
Code:
Private Sub dgCustomerPackage_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgCustomerPackage.CellClick
If TypeOf dgCustomerPackage.CurrentCell Is DataGridViewCheckBoxCell Then
If 1 + 1 = 2 Then
dgCustomerPackage.CurrentRow.Cells("colchkSelect").Value = 0
Else
dgCustomerPackage.CurrentRow.Cells("colchkSelect").Value = 1
End If
End If
End Sub
I am wondering why my "colchkSelect" will be checked even though the above codes showing that it should not be checked when the cell click event?
-
May 18th, 2013, 12:43 AM
#2
Re: Datagridview Checkbox
Only if you click the cell. But, you need to check the type in the IF condition. Your code will always be 0 because 1+1 is 2
-
May 18th, 2013, 10:11 AM
#3
Re: Datagridview Checkbox
I don't think the CheckBox.Value is what you want. You will need to put a checkbox on a form, catch the event, put a break in the event and look at the checkbox to see what actually turns true when the box is checked. I think it is Checked. So if you put dgCustomerPackage.CurrentRow.Cells("colchkSelect").Checked = False I think you will get what you want.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|