Selecting a row in a DataGridView and having the arrow on the row header follow

前端 未结 2 578
迷失自我
迷失自我 2020-12-14 20:08

This is in C#. If I select a row in a DataGridView with DataGridViewRow.Selected = true, the row selects just fine, but the arrow in the \"column header\" (the grey very lef

相关标签:
2条回答
  • 2020-12-14 20:38

    This is straight from google:

    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
    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.
    dataGridView1.CurrentRow.Selected = false;
    dataGridView1.Rows[1].Selected = true;
    
    0 讨论(0)
  • 2020-12-14 20:48

    To answer the second part of you question, make sure your setting the header style for the column to centered as well.

    0 讨论(0)
提交回复
热议问题