我用處理我的複選框單擊事件CurrentCellDirtyStateChanged。當我點擊包含複選框的單元格時,即我單擊單元格時,選中該複選框並調用DirtyStateChanged,我希望能夠處理同一個事件。使用下面的代碼並沒有多大幫助,它甚至不會調用當前的CellDirtyStateChanged的。我已經用完了想法。單擊單元格時檢查Datagridview複選框
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
if(dataGridView.Columns[e.ColumnIndex].ReadOnly != true)
{
//option 1
(dataGridView.CurrentRow.Cells[e.ColumnIndex] as DataGridViewCheckBoxCell).Value = true;
//option 2
DataGridViewCheckBoxCell cbc = (dataGridView.CurrentRow.Cells[e.ColumnIndex] as DataGridViewCheckBoxCell);
cbc.Value = true;
//option 3
dataGridView.CurrentCell.Value = true;
}
}
這是XAML嗎?這將是一個比[單元]和[檢查]更好的問題標籤 – DLeh 2015-04-01 20:51:15
爲什麼這個問題會得到一個負面投票? – Jnr 2015-04-03 11:34:05