我的應用程序中有一個Winforms DataGridView。在Windows窗體中捕獲複選框單擊事件DataGridview
我有兩個複選框列以及來自數據庫的5個其他列。這兩個複選框列都添加了DataGridViewCheckBoxColumn。
當用戶點擊第二個複選框時,如果未選中該行的第一個複選框,則需要向用戶顯示一條消息。
我該如何解決這個問題? 我試過了,但單元格值爲空。 我在做什麼錯?
private void dgTest_CellClick(System.Object sender, DataGridViewCellEventArgs e)
{
DataGridViewCheckBoxCell officialCbCell = row.Cells[1] as DataGridViewCheckBoxCell;
DataGridViewCheckBoxCell includeCbCell = row.Cells[0] as DataGridViewCheckBoxCell;
if (officialCbCell != null)
{
if (officialCbCell.Value != null && (bool)officialCbCell.Value == true)
{
if (includeCbCell != null && (bool)includeCbCell.Value == false)
{
MessageBox.Show("INVALID");
}
}
}
}
謝謝。
對此有任何意見嗎?謝謝。 – Jimmy 2011-03-10 12:51:21