troubleshooting Question

Conversion selected row in datagridview to selected row in datatable

Avatar of Mark Bakelaar
Mark BakelaarFlag for Norway asked on
Visual Basic ClassicVisual Basic.NET
3 Comments1 Solution895 ViewsLast Modified:
Hi Experts,
I have 4 tabpages with a datagridview on them. In each datagridview is a part of a datatable displayed. On each tabpage are also labels displayed (representing 4 compartments). When a user selects a label of one of these compartments a check is made if this label matches the compartment of the selected datagridline.
The problem is that I can check which datagridviewline is selected (selectedASNline), but if I use this value it seems that this value is not the selectedrow of the datatable. How can I convert the selectedrow of the datagridview to the selectedrow on of the datatable?
Any help is appreciated, MB
Dim SelectedASNLine, i As Integer
        Dim CompartmentArea As Label = sender
        'Find the correct datagridview based on the name of the label (sender)
        If CInt(CompartmentArea.Name.Substring(0, 1)) = 1 Then
            SelectedASNLine = Me.DataGridView3.CurrentRow().Index
        ElseIf CInt(CompartmentArea.Name.Substring(0, 1)) = 2 Then
            SelectedASNLine = Me.DataGridView4.CurrentRow().Index
        ElseIf CInt(CompartmentArea.Name.Substring(0, 1)) = 3 Then
            SelectedASNLine = Me.DataGridView5.CurrentRow().Index
            SelectedASNLine = Me.DataGridView6.CurrentRow().Index
        End If
        'Check if the selected compartmentarea and the compartment in ASN match
        If Not ds.Tables("ASNs").Rows(SelectedASNLine)("Compartment").ToString = (CompartmentArea.Name.Substring(0, 2)).ToString Then
            MsgBox("This ASN line is stored in another compartment", MsgBoxStyle.Information)
            Exit Sub
        End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros