Marulasiddesha
Marulasiddesha

Reputation: 11

Remove all rows selection option from datagridview topleft cell click in c#

I am using Data Grid View control in my project and the requirement is below. Row Headers Visible = true, Column Headers Visible = true, Multiple Select = true, Selection Mode = Full Row Select. Allow multiple rows selection true but do not allow to select all rows when user clicks on top left cell.

Please help me!!!!!!!

Upvotes: 0

Views: 1210

Answers (3)

SuperMario
SuperMario

Reputation: 1

Set the RowHeadersVisible to false.

Upvotes: -1

Luis Quijada
Luis Quijada

Reputation: 2405

Thanks to @anchandra response from this other SO thread you may accomplish that behavior by overriding the OnCellMouseDown behaviour:

protected override void OnCellMouseDown(DataGridViewCellMouseEventArgs e)
{
    if (e.RowIndex == -1 && e.ColumnIndex == -1) return;
    base.OnCellMouseDown(e);
}

Upvotes: 0

user1573918
user1573918

Reputation: 3

The top left cell's only purpose is to select all the cells, I don't think that could be disabled.

In any case you can use a if condition to check whether all the rows are selected and proceed accordingly.

ps: I am new to C# and dont know much

Upvotes: 0

Related Questions