[英]DataGridView & Checkbox Column?
Using vb.net and DataGridView in Winforms. 在Winforms中使用vb.net和DataGridView。
What event should I use to know when the checkbox has changed? 我应该使用什么事件知道复选框何时更改?
Did you mean how do you know when the DataGridView changes? 您是说您如何知道DataGridView何时更改?
A DataGridView is not a checkbox at all. DataGridView根本不是复选框。
Add an event handler to handle a CellValueChanged event. 添加事件处理程序以处理CellValueChanged事件。
Private Sub MySubName(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
End Sub
(replace MySubName with whatever you want, and DataGridView1 with the name of your DataGridView). (将MySubName替换为所需的名称,并将DataGridView1替换为您的DataGridView的名称)。
Fill in the body of the Sub to handle the event. 填写Sub的主体以处理事件。
Is 是
DataGridViewCheckBoxCell.EditingCellValueChangedwhat you want? 你想要什么?
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! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.