• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

Help with selecting first row in DataGridView

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
vcharles
Asked:
vcharles
  • 4
  • 2
1 Solution
 
Fernando SotoRetiredCommented:
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
 
vcharlesAuthor Commented:
Hi,

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

Thanks,

Victor
0
 
vcharlesAuthor Commented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
vcharlesAuthor Commented:
Thank You.
0
 
Fernando SotoRetiredCommented:
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
 
vcharlesAuthor Commented:
That is a good idea, will do.

Thanks.

Victor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now