Hi Friends,
How can we focus the cursor on to a particular cell in datagrid.
i.e If in particular cell, I have to check if the user as entered the value or not.
If He has not entered the value I want the cursor to focus to the same cell.
Hi Friends,
How can we focus the cursor on to a particular cell in datagrid.
i.e If in particular cell, I have to check if the user as entered the value or not.
If He has not entered the value I want the cursor to focus to the same cell.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satish KathiPosted Nov 7, 2008, 3:38 PM
You can use Data Grid’s cell validating event
For example in your Data Grid if there are 3 columns
You want second column as required that is user must enter value
Following is the code for Cell validating event
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.ColumnIndex == 1 && (dataGridView1[e.ColumnIndex, e.RowIndex].EditedFormattedValue == null || dataGridView1[e.ColumnIndex, e.RowIndex].EditedFormattedValue.ToString() == string.Empty))
e.Cancel = true;
}
Hope this helps