2009-12-24 50 views

回答

1

你是不是指你怎么知道DataGridView何时改变?

DataGridView根本不是复选框。

添加一个事件处理程序来处理CellValueChanged事件。

Private Sub MySubName(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged 

End Sub 

(用任何你想要的替换MySubName,用你的DataGridView的名称替换DataGridView1)。

填写Sub的主体来处理事件。

0

DataGridViewCheckBoxCell.EditingCellValueChanged
你想要什么?

+0

什么是DataGridViewCheckBoxCell?这样的类型会得到一个错误。 – Alex 2009-12-24 03:48:54

+0

你有一个DataGridViewCheckBoxColumn的权利?他们有DataGridViewCheckBoxCell作为单元格类型:http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcell.aspx – John 2009-12-24 08:26:11

0

您需要设置一个事件处理程序以在单元格的内容发生更改时进行工作。然后,根据传递的参数,您可以看到复选框是否已选中或未选中,并相应地进行工作。

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 

希望有帮助!