Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

VB 2008  - How to Select rows in a DataGridView

Posted on 2009-07-09
Last Modified: 2012-05-07
How do I select a row, or several rows (if multi-select) in a DataGridView?
Question by:ljcor
  • 3
  • 3
LVL 15

Accepted Solution

JackOfPH earned 500 total points
ID: 24811891
What do you mean? Select? Highlight multiple rows?

Try this, The following code will select the first and third row in the datagridview

Datagridview1.Rows(0).Selected = True  
Datagridview1.Rows(2).Selected = True

Author Closing Comment

ID: 31601493
Yes, that is exactly what I wanted to do.   Thanks again.  Today I remember where you live!!  Italy?
Just kidding.  I do remember.
LVL 15

Expert Comment

ID: 24811915
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.


Author Comment

ID: 24811960
Perhaps you can add to this answer just so I know:  How can I select ALL rows in the grid?

For each row in MyDataGridView  (or something like that?)


LVL 15

Expert Comment

ID: 24819468
Here: Sorry for the long response, I went home early yesterday... here is the code you want to do...

For each row as DatagridviewRow in MyDatagridview.rows
row.Selected = true

Open in new window


Author Comment

ID: 24820119
I can always wait for a right answer.  Thanks Jack.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question