DataGridView without selected row at the beginning

后端 未结 12 1059
栀梦
栀梦 2021-02-12 14:23

In my WinForms I have DataGridView. I wanted to select full row at once so I set SelectionMode as FullRowSelect. And now I have problem, b

12条回答
  •  花落未央
    2021-02-12 14:56

    You can call dataGridView.ClearSelection() method inside form_Load event like this...

        private void Form1_Load(object sender, EventArgs e)
        {
         // You will get selectedCells count 1 here
         DataGridViewSelectedCellCollection selectedCells = dataGridView.SelectedCells;
         // Call clearSelection 
         dataGridView.ClearSelection();
         // Now You will get selectedCells count 0 here
         selectedCells = dataGridViewSchedule.SelectedCells;
        }
    

提交回复
热议问题