I m making a DataGridView
with a series of Checkboxes in it with the same labels horizontally and vertically. Any labels that are the same, the checkboxes will be inactive, and I only want one of the two "checks" for each combination to be valid. The following screenshot shows what I have:
在下半月检查之后,我想联合国检查。 因此,如果对[质量、垃圾邮件][7、8]零基的坐标进行核对,我就希望[垃圾邮件、qu][8、7]不受检查。 我迄今所做的是:
dgvSysGrid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
dgvSysGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
string[] allsysNames = { "heya", "there", "lots", "of", "names", "foo", "bar", "quux", "spam", "eggs", "bacon" };
// Add a column for each entry, and a row for each entry, and mark the "diagonals" as readonly
for (int i = 0; i < allsysNames.Length; i++)
{
dgvSysGrid.Columns.Add(new DataGridViewCheckBoxColumn(false));
dgvSysGrid.Columns[i].HeaderText = allsysNames[i];
dgvSysGrid.Rows.Add();
dgvSysGrid.Rows[i].HeaderCell.Value = allsysNames[i];
// Mark all of the "diagonals" as unable to change
DataGridViewCell curDiagonal = dgvSysGrid[i, i];
curDiagonal.ReadOnly = true;
curDiagonal.Style.BackColor = Color.Black;
curDiagonal.Style.ForeColor = Color.Black;
}
// Hook up the event handler so that we can change the "corresponding" checkboxes as needed
//dgvSysGrid.CurrentCellDirtyStateChanged += new EventHandler(dgvSysGrid_CurrentCellDirtyStateChanged);
dgvSysGrid.CellValueChanged += new DataGridViewCellEventHandler(dgvSysGrid_CellValueChanged);
}
void dgvSysGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
Point cur = new Point(e.ColumnIndex, e.RowIndex);
// Change the diagonal checkbox to the opposite state
DataGridViewCheckBoxCell curCell = (DataGridViewCheckBoxCell)dgvSysGrid[cur.X, cur.Y];
DataGridViewCheckBoxCell diagCell = (DataGridViewCheckBoxCell)dgvSysGrid[cur.Y, cur.X];
if ((bool)(curCell.Value) == true)
{
diagCell.Value = false;
}
else
{
diagCell.Value = true;
}
}
/// <summary>
/// Change the corresponding checkbox to the opposite state of the current one
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void dgvSysGrid_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
Point cur = dgvSysGrid.CurrentCellAddress;
// Change the diagonal checkbox to the opposite state
DataGridViewCheckBoxCell curCell = (DataGridViewCheckBoxCell)dgvSysGrid[cur.X, cur.Y];
DataGridViewCheckBoxCell diagCell = (DataGridViewCheckBoxCell)dgvSysGrid[cur.Y, cur.X];
if ((bool)(curCell.Value) == true)
{
diagCell.Value = false;
}
else
{
diagCell.Value = true;
}
}
问题在于,如果我使用<代码>,电池价值的变化似乎总是“落后”。 手机/密码”活动,我不敢肯定,如果Im在“ir脏”状态下出现“d脏”状态时,如何进入目前的囚室(使目前的囚室地址错了,但我确实没有尝试过这种价值),这就是说,这条道路根本不可行。
基本上,我如何以正确的 b干价值处理“权利”问题,以便我的疏漏算法发挥作用?