Solved

Help with selecting first row in DataGridView

Posted on 2014-03-10
6
416 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
  • 4
  • 2
6 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Closing Comment

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

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now