Try the code specified below
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int myRow = 2;
int myCol = 2;
if ((e.RowIndex == myRow) & (e.ColumnIndex == myCol))
{
DateTimeForm myDTForm = new DateTimeForm();
if (myDTForm.ShowDialog()== DialogResult.OK)
{
((DataGridView)sender)[myCol, myRow].Value = myDTForm.Tag;
((DataGridView)sender).Invalidate();
}
}
}
I did not test this code. I found it while I was searching for some other query.
If that is not working let me know so that I can try fixing the code.