Reputation: 5729
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
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
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