DataGridView CellSelect and FullRowSelect

So, I have some datagridview that we set to FullRowSelect . Users are now requesting selections on individual cells for copy functions.

I set the DataGridView to CellSelect , but when I launch the application, when I click on the row header, it does not highlight Full Row, but only the first column.

I tried using RowHeaderMouseClick with CellMouseClick to switch the selection mode, but in order for RowHeaderMouseClick completely select it, I need to click on the row header several times.

 private void DataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; } 

How easy or not easy to switch between CellSelect and FullRowSelect back and forth depending on what they have selected in the grid?

+7
source share
4 answers

If I understand you, do you want to be able to select individual cells, but is it also easy to select a complete row?

If in this case set SelectionMode to RowHeaderSelect .

+13
source
 DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; 

1- Actually, you are using a DataGridView structure, not a DataGridView object.

2. SelectionMode should not be changed every time the user clicks a line, but in your constructor of your program.

Example

 public MyForm() { dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect; } 
+2
source

add this code.

 this.dataGridView1.SelectionMode = isTrue == true ? DataGridViewSelectionMode.FullRowSelect : DataGridViewSelectionMode.RowHeaderSelect; 
0
source

this.dataGridViewEmpList.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

-one
source

All Articles