Remove blue colored row from DataGridView WinForms

后端 未结 5 830
有刺的猬
有刺的猬 2020-12-21 17:09

When I fill a DataGridView row by row (calling it\'s add function), the top row gets blue colored. It\'s not selected because I tried ClearSelection() also but it didnt work

5条回答
  •  半阙折子戏
    2020-12-21 17:36

    To achieve this along with the ClearSelection you will need to set one more property

    Try this in the DataBindingComplete

    dataGridView1.ClearSelection();
    dataGridView1.CurrentCell = null;
    

    EDIT

    Based on your comments you can modify the code as

    if (e.KeyCode == Keys.Up && dataGridView1.CurrentCell.RowIndex == 0)
    {                   
         this.ActiveControl = textBoxPartySearch;
         dataGridView1.Refresh();
         dataGridView1.ClearSelection();
         dataGridView1.CurrentCell = null;
         e.Handled = true;
    }
    

提交回复
热议问题