我有一个checkbox
我datagridview
需要一个是/否弹出窗口来确认 SQL 端的事务。这部分工作正常,但如果我选择否,复选框仍会选中。
我将如何确保复选框在 UI 上具有正确的值?
我使用cellcontentclick
的代码在其中,正确复选框的代码如下:
if (e.ColumnIndex.ToString() == "3")
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)caseSelectorDataGridView.Rows[e.RowIndex].Cells[3];
DataGridViewRow row = caseSelectorDataGridView.Rows[e.RowIndex] as DataGridViewRow;
System.Data.DataRowView SelectedRowView;
newCityCollectionDataSet.CaseSelectorRow SelectedRow;
SelectedRowView = (System.Data.DataRowView)caseSelectorBindingSource.Current;
SelectedRow = (newCityCollectionDataSet.CaseSelectorRow)SelectedRowView.Row;
DialogResult dialogResult = MessageBox.Show("Are you sure?", "WARNING", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes && Convert.ToBoolean(checkCell.Value) == false)
{
if (Convert.ToBoolean(checkCell.Value) == false && caseSelectorDataGridView.IsCurrentCellDirty)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var matchedCaseNumber = (from c in dc.GetTable<CaseSelector>()
where c.CaseNumberKey == SelectedRow.CaseNumberKey
select c).SingleOrDefault();
var matchedCaseNumberProp = (from d in dc.GetTable<PropertyInformation>()
where d.CaseNumberKey == SelectedRow.CaseNumberKey
select d).SingleOrDefault();
DateTime today = DateTime.Now;
DateTime firstDay = new DateTime(today.Year, today.Month, 1);
reportsSent newReport = new reportsSent();
newReport.CaseNumberKey = SelectedRow.CaseNumberKey;
dc.reportsSents.InsertOnSubmit(newReport);
matchedCaseNumberProp.DateFinished = DateTime.Now;
matchedCaseNumberProp.Finished = -1;
dc.SubmitChanges();
SelectedRow.FinishedDate = DateTime.Now;
SelectedRow.FinishedID = Globals.GlobalInt;
SelectedRow.Finished = -1;
caseSelectorTableAdapter.Update(newCityCollectionDataSet);
var qry = dc.PropertyInformations.Where(c => c.DateFinished >= firstDay && c.DateFinished <= today && c.ClientKey == 2).Count();
var qry1 = dc.PropertyInformations.Where(c => c.DateFinished >= firstDay && c.DateFinished <= today && c.ClientKey == 3).Count();
txtFinished.Text = Convert.ToString(qry);
txtGRBFinished.Text = Convert.ToString(qry1);
txtFinished.Text = Convert.ToString(qry);
PerformRefresh();
}
}
else if (dialogResult == DialogResult.No)
{
}
}