HarryBeasant HarryBeasant - 1 year ago 89
Vb.net Question

Selecting single cell data from selected row - DataGridView

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?

Answer Source

Perhaps the right syntax is:

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

See MSDN docs

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download