?
Solved

Vb.net 2008 Datagridview selected

Posted on 2009-04-20
4
Medium Priority
?
369 Views
Last Modified: 2012-05-06
I got 1 datagridview with 4 column and many row.if user select one row of datagridview.
how to retrive string value for each column?
0
Comment
Question by:aarontham
  • 2
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24182700
This will give the value for the first column of the selected row. You just need to change the 0 to 1, 2 and 3 for the other ones
    Private Sub DataGridView1_RowEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowEnter
        If Me.DataGridView1(0, e.RowIndex).Value IsNot Nothing Then
            Debug.WriteLine(Me.DataGridView1(0, e.RowIndex).Value.ToString)
        End If
    End Sub

Open in new window

0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24182715
This shows all values
    Private Sub DataGridView1_RowEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowEnter
        For Each col As DataGridViewColumn In Me.DataGridView1.Columns
            Debug.WriteLine(Me.DataGridView1(col.Index, e.RowIndex).Value)
        Next
    End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24182811

Private Sub RetrieveValueOfCell()

For each row as datagridviewrow in DataGridView1.SelectedRows
     msgbox(Row.Cells(0).value)  'Retrieve the first cell
     msgbox(Row.Cells(1).value)  'Retrieve the first cell
Next

End Sub
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24182813
Private Sub RetrieveValueOfCell()

For each row as datagridviewrow in DataGridView1.SelectedRows
     msgbox(Row.Cells(0).value)  'Retrieve the first cell
     msgbox(Row.Cells(1).value)  'Retrieve the Second cell
Next

End Sub
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

807 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