help in datagride view CellLeave
-
Dear Experts, I have datagridView with tow columns. I use the below code to get value from Cell the cursor left, but when cursor left for first time, even if I filled a value, the message box give me "Blank" notjing, but if I returned to the cell and leave it again, then message give me the Value. I have searched in google, but with no result.
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;MessageBox.Show(x); }
Your help please. Ahmad,
-
Dear Experts, I have datagridView with tow columns. I use the below code to get value from Cell the cursor left, but when cursor left for first time, even if I filled a value, the message box give me "Blank" notjing, but if I returned to the cell and leave it again, then message give me the Value. I have searched in google, but with no result.
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;MessageBox.Show(x); }
Your help please. Ahmad,
Just subscribe to the CellValueChanged[^]-event instead of the CellLeave-event.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
-
Dear Experts, I have datagridView with tow columns. I use the below code to get value from Cell the cursor left, but when cursor left for first time, even if I filled a value, the message box give me "Blank" notjing, but if I returned to the cell and leave it again, then message give me the Value. I have searched in google, but with no result.
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;MessageBox.Show(x); }
Your help please. Ahmad,
put datagridview1.EndEdit() above string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; statement
-
put datagridview1.EndEdit() above string x = (string)dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; statement