I have a data grid with a calendar column. What I want to do is an event (not sure which one is suitable), and this is what should happen:
Update()
) - I already have the method figured out. I just don't know how to do the whole check to see if a value has been changed. CellValueChanged
doesn't work as it is triggered if anything changed on the grid, such as loading the data etc. Is there something else I can use?
Let me know if I need to add more info, I'm not quite sure how to do this.
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
DataGridViewColumn column = dataGridView1.Columns[e.ColumnIndex];
if (column.Name == "dateColumn")
{
UpdateStuff();
}
}
private void UpdateStuff()
{
object myDate = dataGridView1.CurrentCell.Value;
}
private void dgvResults_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var selectedColumn = this.dgvResults.Columns[e.ColumnIndex];
var vm = (PurchaseOrdersTrackingViewModel) this.dgvResults.Rows[e.RowIndex].DataBoundItem;
if (selectedColumn.Name == this.colDueDate.Name)
{
this.SingleDueDate = Convert.ToDateTime(this.dgvResults.Rows[e.RowIndex].Cells[this.colDueDate.Index].Value);
if (!this._mapicsWorkday.IsWorkDay(this.SingleDueDate.Date))
{
this.ShowMessage("Due date selected must be a valid working day.");
return;
}
if (this.SingleDueDate.Date < DateTime.Today)
{
this.ShowMessage("You cannot set a past date as a due date.");
return;
}
vm.HasCommentUpdateApplied = true;
this.UpdateSingleOrder = true;
this._presenter.BulkUpdateItems();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.