[RESOLVED] [2005] Get cell content from selected row in DataGridView
Hello.
This is what I want to do:
On DataGrid double click, I want to return the value of the 1st cell from the selected row. I've done this code but it doesn't work very well.
Code:
Private Sub DataGridView1_CellContentDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentDoubleClick
Me.TextArtigo.Text = Me.DataGridView1.Item(e.ColumnIndex, 1).Value
End Sub
Thank you.
Re: [2005] Get cell content from selected row in DataGridView
This should do it for you... Notice that I'm handling the CellDoubleClick event (so that even if the user doubleclicks outside of the actual content of the cell (but still within the cell's boundary), it still works)
Code:
Private Sub DataGridView1_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
Me.TextArtigo.Text = Me.DataGridView1.Item(0, e.RowIndex).Value.ToString()
End Sub
Re: [2005] Get cell content from selected row in DataGridView
Thank you.
That work's pretty good! :)