Hi Victor,
In a DataGridView, the selected row and the current row (indicated by an
arrow in the row header) may not be the same row. In addition, we could
select multiple rows in a DataGridView but the current row can only be one
row.
When the SelectionMode property of the DataGridView is set to
FullRowSelect, the current row will be always selected.
If you'd like to change the current row in a DataGridView control, you may
set the CurrentCell property. The following is a sample.
(change the current row to the row with index of 1)
VB.net:
DataGridView1.CurrentCell = DataGridView1.Rows(1).Cells(0)
C#:
dataGridView1.CurrentCell = dataGridView1.Rows[1].Cells[0];
If you'd like to just change the selected row, you may set the Selected
property of the row you want to true. The following is a sample.
(change the selected row to the row with index of 1)
VB.net:
DataGridView1.CurrentRow.Selected = False
DataGridView1.Rows(1).Selected = True
C#:
dataGridView1.CurrentRow.Selected = false;
dataGridView1.Rows[1].Selected = true;
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.