So I have several datagridviews that we had set to FullRowSelect
. The users are now requesting the ability to select on single cells for copy functions.
I set the DataGridView
to CellSelect
but when I run the app, when I click on the Row Header it doesn't highlight the Full Row, only the first column.
I tried using the RowHeaderMouseClick
with a CellMouseClick
to get the selection mode to shift but in order for RowHeaderMouseClick
to select it fully I am having to click on the row header multiple times.
private void DataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
How can I easily or not so easily switch back and forth between CellSelect
and FullRowSelect
depending on what they have selected on the grid?
If I understand you, you want to be able to select single cells but also easily select a full row?
If that's the case, set SelectionMode to RowHeaderSelect
.
DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
1- You are actually using the DataGridView Structure, and not your object DataGridView.
2- The SelectionMode shouldn't be modified every time the user click a Row, but in your Constructor of your program.
Example
public MyForm()
{
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
}
add this one line code.
this.dataGridView1.SelectionMode = isTrue == true ? DataGridViewSelectionMode.FullRowSelect : DataGridViewSelectionMode.RowHeaderSelect;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With