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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satish KathiRank #8,369 · 223 reputationPosted Nov 7, 2008, 10:38 AM EST
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