Reputation: 159
In my WinForms project I have a Form
with a DataGridView
. When the application loads, the DataGridView
is filled with data. In myDataGridView
, SelectionMode
is set to FullFowSelect
.
Question 1: When the Form
loads, how can I make it so that no row is selected in the DataGridView
?
Question 2: And after the initial load, how can I program a Button
to highlight a specific row (for example, the 5th row) in the DataGridView
?
Upvotes: 1
Views: 231
Reputation: 6651
datagridview.Rows[index].Selected = true;
in your case to select fifth row
datagridview.Rows[4].Selected = true;
Upvotes: 1
Reputation: 38200
I believe you should set CurrentCell for the DataGridView
So for your case fifth row should be
dataGridView1.CurrentCell = dataGridView1[0, 4];
Upvotes: 1