Solved

VB 2008  - How to Select rows in a DataGridView

Posted on 2009-07-09
6
253 Views
Last Modified: 2012-05-07
How do I select a row, or several rows (if multi-select) in a DataGridView?
0
Comment
Question by:ljcor
[X]
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
  • 3
  • 3
6 Comments
 
LVL 15

Accepted Solution

by:
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
0
 

Author Closing Comment

by:ljcor
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.
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24811915
:)
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:ljcor
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?)

Next

???
0
 
LVL 15

Expert Comment

by:JackOfPH
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
 
Next

Open in new window

0
 

Author Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

623 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