Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programatically select first row of DataGridView [duplicate]

Tags:

c#

winforms

Possible Duplicate:
Selecting a row in Datagridview Programatically?

I am developing a new desktop application in C# using Windows Forms. In one of my form i put the DataGridView Control and i am populating this dataGridViewControl Dynamically using my custom functions.

Now after populating the above control, is there any way to programatically select the first row of that DataGridViewview. Note: the Selection mode property of this DataGridView is set to "Full row Select"

like image 354
Jame Avatar asked Aug 04 '11 04:08

Jame


2 Answers

Try:

dataGridView1.Rows[0].Selected = true;
like image 70
Jay Riggs Avatar answered Nov 14 '22 08:11

Jay Riggs


To select one row in winform DataGridView TRY THIS:

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

It works ..

like image 38
Tarek Sultan Avatar answered Nov 14 '22 09:11

Tarek Sultan