Hi all,
What I want to do is, when I leave a cell I want to make sure that that cell is not null, that is there is a date data there, and when I leave, I want to add some days to date and place this result on another cell. This is how I tried it.
private void tblgrid1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridViewRow dgvRow = tblgrid1.CurrentRow;
//here I can't get this code to function even if I'm on right cell....problem here...
if (dgvRow.Cells["colStartDate"].Selected)
{
// here I actually want to test if null, appreciate a better code if you have
if (Convert.ToDateTime(dgvRow.Cells["colStartDate"].Value) > Convert.ToDateTime("01/01/1900"))
{
if (Convert.ToInt32(dgvRow.Cells["colDayPast"].Value) > 0 )
{
dgvRow.Cells["colEndDate"].Value = (Convert.ToDateTime(dgvRow.Cells["colStartDate"].Value)).AddDays(Convert.ToInt32(dgvRow.Cells["colDayPast"].Value)).ToShortDateString();
}
}
}
}
I appreciate any help
thanks
snky