M
Mohanmj
Guest
I have used DateTime column in datagridview and DateTime format is "t".
Code
this.dataGridView1.Columns["Date"].DefaultCellStyle.Format = "t";
I have tried to change the date time value then endedit the CellValidating event now i got the current date let me know the reason for this.
Code
this.dataGridView1.CellValidating += DataGridView1_CellValidating;
private void DataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (this.dataGridView1.CurrentCell.IsInEditMode)
{
var value1 = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
this.dataGridView1.CellValidating -= DataGridView1_CellValidating;
this.dataGridView1.EndEdit();
var value2 = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
}
}
Screenshot

Sample link: TestDateTime.zip
Let me know how can i overcome this?
Thanks,
Mohanraj G
Mohanraj G
Continue reading...
Code
this.dataGridView1.Columns["Date"].DefaultCellStyle.Format = "t";
I have tried to change the date time value then endedit the CellValidating event now i got the current date let me know the reason for this.
Code
this.dataGridView1.CellValidating += DataGridView1_CellValidating;
private void DataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (this.dataGridView1.CurrentCell.IsInEditMode)
{
var value1 = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
this.dataGridView1.CellValidating -= DataGridView1_CellValidating;
this.dataGridView1.EndEdit();
var value2 = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
}
}
Screenshot

Sample link: TestDateTime.zip
Let me know how can i overcome this?
Thanks,
Mohanraj G
Mohanraj G
Continue reading...