Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGridView select multiple rows

Status
Not open for further replies.

MangroBongacello

Programmer
Mar 20, 2001
189
SI
I'm trying to create a procedure to search DataGridView. I would like a program to select all rows, where search string is found.

Is it possible to select multiple rows in datagridview through code since the SelectedRows property is read only?

Thank you, Mangro
 
I think you can just do a Select on the DataGridView. For example, the following will select the first, third and fifth rows (assuming there are five or more rows in the grid):

DataGridView1.Select(0)
DataGridView1.Select(2)
DataGridView1.Select(4)


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Thanks for the reply.

The Select method does not accept any arguments. I think what it does is sets the focus to the control.

Anyway, I found the solution - not exactly what I wanted, but hey...

Grid.Rows(x).Cells(y).Selected=True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top