Make it possible to ONLY select one row in datagrid?

Viewed 35615

I want my datagrid to only allow one row to selected.

I guess I can do this by adding code to the datagridviews selectionChanged-event, but is there a better solution?

I would prefer to just have a property to set, i.e. : mydatagridview.maximumNrOfRowsSelected = 1; or something similar.
Is there anything like this?

3 Answers

The DataGridView has a Property called MultiSelect ( default True ).

Set this to False.

Adriaan's answer didn't work for me, but Oscar's got me on the right track. Maybe something changed since Adriaan posted.

To get it working for me I changed SelectionMode to FullRowSelect.

Related