Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to select all rows in DataGridView?

Tags:

c#

winforms

how to select all rows in DataGridView on pressing a button ?

i work on C# winforms

like image 318
Gali Avatar asked Feb 14 '11 21:02

Gali


2 Answers

DataGridView.SelectAll Method

as easy as calling SelectAll :)

make sure the property multiselect is set to true

like image 115
Davide Piras Avatar answered Oct 02 '22 20:10

Davide Piras


dataGridView.SelectAll()

this selects all the DatagridView including the ColumnHeaders . But if you want that the ColumnHeaders will not be included

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

Please vote :) Thanks a lot...

like image 40
nate wew Avatar answered Oct 02 '22 21:10

nate wew