我有以下代码在CheckedChanged
复选框事件上运行。
/// <summary>
/// Determine whether to select all order records
/// </summary>
/// <param name="sender">determine sender object</param>
/// <param name="e">event args</param>
private void CbSelectAll_CheckedChanged(object sender, EventArgs e)
{
if (this.dgvOrderLines.Rows.Count != 0)
{
bool value = this.CbSelectAll.Checked;
for (int i = 0; i < this.dgvOrderLines.RowCount; i++)
{
this.dgvOrderLines[0, i].Value = value;
}
if (value)
{
this.btnFailed.Enabled = true;
this.BtnDownload.Enabled = true;
}
else
{
this.btnFailed.Enabled = false;
this.BtnDownload.Enabled = false;
}
}
}
问题是这似乎并没有真正更新下划线DataSource
。它循环通过的复选框列在视觉上更新得很好。
因此,当我执行以下操作时,在用户按下按钮后,选中的行在复选框列中仍然有一个 false 值。
Order[] orderlines = ((SortableBindingList<Order>)this.dgvOrderLines.DataSource).Where(x => x.Include == true).ToArray();
关于我要去哪里错的任何想法?