2009-12-24 30 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 

希望有幫助!