How to programmatically select the first row of a DataGridView

Possible duplicate:
Datagridview row selection programmatically?

I am developing a new desktop application in C # using Windows Forms. In one of my forms, I put a DataGridView Control , and I populate it with dataGridViewControl Dynamically using my custom functions.

Now, after filling in the above control, is there a way to programmatically select the first row of this DataGridViewview . Note. The selection mode property of this DataGridView is set to Full Row Selection.

+4
source share
2 answers

Try:

 dataGridView1.Rows[0].Selected = true; 
+19
source

To select one row in winform DataGridView TRY THIS:

 dataGridView1.MultiSelect = false; dataGridView1.MultiSelect = true; dataGridView1.Rows[RowIndex].Selected = true; 

It works.

+3
source

All Articles