Vb.net – Selecting single cell data from selected row – DataGridView

vb.net

I have a datagridview with data in it, I have set it so you can only select the row and one at a time.

However, I need to get the data from one of the cells in the selected row, I have tried this;

Dim data As String = DataGridView1.SelectedRows.Cells(5).toString

Something like that, but I can't get the value of it, does anyone know the way to do it?

Best Answer

Perhaps the right syntax is:

Dim data As String = DataGridView1.SelectedRows(0).Cells(5).Value.ToString 

See MSDN docs