Walter Fabio Simoni
Walter Fabio Simoni

Reputation: 5729

Allow row selecting in a dataGridview but don't allow cell selecting

I would like to allow row selecting in a DataGridView ( C#, WinForm ) and don't allow cell selecting.

Is there a way to do this please ?

Thanks a lot :)

Upvotes: 4

Views: 10566

Answers (2)

dandan78
dandan78

Reputation: 13864

Check your Properties window in Visual Studio after selecting the DataGridView. You'll notice a property called SelectionMode. Set it to FullRowSelect.

Upvotes: 14

Kirill Shlenskiy
Kirill Shlenskiy

Reputation: 9587

this.DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.DataGridView.Columns["Text"].ReadOnly = true;

DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect means individual cells cannot be selected.

DataGridViewColumn.ReadOnly = true means that cells cannot be double-clicked into.

Upvotes: 3

Related Questions