[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Help with highlighting rows in multiple Grids based on row selected from one Grid

Posted on 2014-03-09
Medium Priority
Last Modified: 2014-03-10

I have four DataGrid with data from different tables, but they all have the same SN column,
when I click on a column on either DataGrid, how do I highlight the rows in the other grids with the matching SN value?


Question by:vcharles
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
  • 2

Author Comment

ID: 39916084
Hi again,

is it possible to use both SN and country instead of only SN, I will have multiple identical SN
values, therefore will need to add the country column to highlight the appropriate columns in the other grids.


LVL 64

Accepted Solution

Fernando Soto earned 2000 total points
ID: 39916301
Hi Victor;

This code snippet should do what you want. Note that I placed the code in CellClick event so I can get the current row.

Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick

    ' Clear the selection in all the DataGridView's

    ' Get the currently select row
    Dim index1 As Integer = DataGridView1.CurrentRow.Index
    ' Select that row in DataGridView1
    DataGridView1.Rows(index1).Selected = True

    ' Get all the row indexs in DataGridView2 That match the criteria
    Dim childRows = From row As DataGridViewRow In DataGridView2.Rows _
                    Where row.Cells("SN").Value = DataGridView1.Rows(index1).Cells("SN").Value AndAlso _
                          row.Cells("CTRY").Value = DataGridView1.Rows(index1).Cells("CTRY").Value _
                    Select row.Index

    ' Select all the matching rows
    For Each idx In childRows
        DataGridView2.Rows(idx).Selected = True

End Sub

Open in new window


Author Comment

ID: 39916377

Thank You very much, I will try it and get back to you later.


Author Closing Comment

ID: 39916909
It works!

Thank You.

LVL 64

Expert Comment

by:Fernando Soto
ID: 39917082
Not a problem Victor, glad to help.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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