我有一个 TabControl,每个 TabPage 上都有一个 DataGridView。DataGridView 在 Column[0] 中有一个 DataGridViewCheckBoxCell。
我想取消选中所有 TabPages 的 DataGridView 同一行上的 DataGridViewCheckBoxes。
我只能在单击的 TabPage 上访问 DataGridView。看起来 myDataGrid_CellContentClick 事件的发送者对象不包含其他 TabPages。
如何在其他 TabPages 上设置复选框。
void myDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int clickedRow = e.RowIndex;
int clickedColumn = e.ColumnIndex;
if (clickedColumn != 0) return;
DataGridView myDataGridView = (DataGridView)sender;
if (!ToggleAllRowSelection)
{
foreach (TabPage myTabPage in tabControl1.TabPages)
{
foreach (DataGridViewRow myRow in myDataGridView.Rows)
{
if (myRow.Index == clickedRow)
{
((DataGridViewCheckBoxCell)myRow.Cells[0]).Value = false;
}
}
}
}
}