?
Solved

Help with selecting first row in DataGridView

Posted on 2014-03-10
6
Medium Priority
?
425 Views
Last Modified: 2014-03-11
Hi,

After I load the GridView with a Data Table, How do I automatically select the first row, required to activate data in another Grid.

If FilteredDTA.Rows.Count > 0 Then
                Me.C1A.DataSource = FilteredDTA
               C1A.Rows(0).Selected = True '*** Does not work
End If

Thanks,

Victor
0
Comment
Question by:vcharles
[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
  • 4
  • 2
6 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 39919655
Hi Victor;

This command, C1A.Rows(0).Selected = True, should be selecting the first row of the DataGridView C1A. What will not be happening is the automatic selection of the matching rows in the other DataGridView because that is being selected through code. If you want them to be selected you need to call the code that selects them.
0
 

Author Comment

by:vcharles
ID: 39920032
Hi,

I thought so too, but the first row is not highlighted, shouldn't it be highlighted when selected?

Thanks,

Victor
0
 

Author Comment

by:vcharles
ID: 39920272
Hi,

My mistake, I used the wrong code. Since the code to load the first Grid is in the Form load event, to activate the code to view the data in the other other grid, I will also include the code in the Formload event.

Thanks,

Victor
0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 

Author Closing Comment

by:vcharles
ID: 39920348
Thank You.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39920413
You may want to place that code in a Sub so that when you need it you can make a single call to it.
0
 

Author Comment

by:vcharles
ID: 39920493
That is a good idea, will do.

Thanks.

Victor
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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

752 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