How to select all rows in a DataGridView?

How to select all rows in a DataGridView when a button is clicked?

I am working on winforms c #

+5
source share
2 answers

Method DataGridView.SelectAll

as simple as calling SelectAll :)

make sure the property is multiselectset to true

+6
source
dataGridView.SelectAll()

it selects all DatagridViews, including ColumnHeaders. But if you want ColumnHeaders not to be included

dataGridView.ColumnHeaders.Visible = false; dataGridView.SelectAll(); dataGridView.ColumnHeaders.Visible = true;

Please vote :) Thanks a lot ...

+2
source

All Articles