?
Solved

get column data from selected row vb.net

Posted on 2016-09-19
8
Medium Priority
?
40 Views
Last Modified: 2016-09-19
I have this code that gets the count of selected rows ok but I want the string of whats shown on the attached as opposed to the index number of the row. not sure how to do that.

[code][code]
    Private Sub PanelLinkShort_Click(sender As Object, e As EventArgs) Handles PanelLinkShort.Click


        Dim selectedRowCount As Integer =
           DataGridViewStringsBulk.Rows.GetRowCount(DataGridViewElementStates.Selected)
        Dim x As String
        If selectedRowCount > 0 Then

            Dim i As Integer
            For i = 0 To selectedRowCount - 1

                'get rows
                x = DataGridViewStringsBulk.SelectedRows(i).Index.ToString()


            Next i


            MessageBox.Show("Finished")

        End If

    End Sub

Open in new window

[/code][/code]

ex
0
Comment
Question by:PeterBaileyUk
  • 5
  • 3
8 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 41804660
Could it be:

x = DataGridViewStringsBulk.SelectedRows(i)("CertainColumn").Value

Open in new window

0
 

Author Closing Comment

by:PeterBaileyUk
ID: 41804663
thank you
0
 

Author Comment

by:PeterBaileyUk
ID: 41804664
should it have a dot between?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:PeterBaileyUk
ID: 41804666
this part is underlined red: DataGridViewStringsBulk.SelectedRows(i)
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41804671
what do you mean? I have copied the name of your control from your code so it should be good? Where have you placed the new line of code? Inside your loop I hope! What is the error message that you get?
0
 

Author Comment

by:PeterBaileyUk
ID: 41804681
it says it cannot be indexed because datagridviewrow has no default property

      If selectedRowCount > 0 Then

            Dim i As Integer
            For i = 0 To selectedRowCount - 1

                'get rows


                x = DataGridViewStringsBulk.SelectedRows(i)("Strshort").Value
            Next i


            MessageBox.Show("Finished")

        End If

Open in new window

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41804693
replace it with :
x = DataGridViewStringsBulk.SelectedRows(i).Cells("Strshort").Value

Open in new window

0
 

Author Comment

by:PeterBaileyUk
ID: 41804702
yes that got it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 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