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

VB.net DataGridView get just row indexes of cells selected

Hi

I often need to loop through the row indexes of cells selected in a DataGridView
without looping through every cell
Is there a way to loop through just the unique rows selected?
1
Murray Brown
Asked:
Murray Brown
  • 2
1 Solution
 
KimputerCommented:
Just some code to help you along the way (I hope).
        Dim myUniqueList As List(Of Integer)
        myUniqueList = New List(Of Integer)



        For counter = 0 To (DataGridView1.SelectedCells.Count - 1)


            If Not myUniqueList.Contains(DataGridView1.SelectedCells(counter).RowIndex) Then myUniqueList.Add(DataGridView1.SelectedCells(counter).RowIndex)

        Next

        For Each uniques In myUniqueList
            MsgBox(uniques)
        Next

Open in new window

0
 
CodeCruiserCommented:
Does looping through the DataGridView.SelectedRows collection not work?
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
No. I have tried that
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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