Getting the value of a selected DataGridView row/column

A

atlewis

Hi,

I'm trying to grab a string of the value in the first column of a
DataGridView object on the selected row. What's the easiest way to go
about that?

I'm building part of a SQL statement inside a loop:

strSQL &= Str(myGrid.SelectedRow(ColumnIndex)) & "," &
Str(dgvResults.Item(1, i)) & "," & Str(Now) & ")"

Obviously, there's no "myGrid.SelectedRow(ColumnIndex)" function.
There's SelectedRows(Index), but that's for something else. What
should I use?

Thanks,

Andy
 
G

Guest

Hi,
try this code:
DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells().Value
 
A

atlewis

Hi,
try this code:
DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells().Value
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.









- Show quoted text -

That was it! Thank you very much.

Andy Lewis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top