i have a problem when i click to item in datagridview to get more information ! ok ? my code :
Try
If (DataGridView1.Rows.Count = 0) Then Return
You are trying to access the DataGridView like an array, when you need to specify that you're looking in the rows and columns. Instead of
DataGridView1(2, DataGridView1.SelectedRows(0).Index).Value
you can write
DataGridView1.Columns(2).Cells(DataGridView1.SelectedRows(0).Index).Value
However, relying on SelectedRows is not the best way to do it. What if the user accidentally selected a few rows and clicked the bottom one?
Assuming your code is in a CellClick handler with
(sender As Object, e As DataGridViewCellEventArgs)
you should use the DataGridViewCellEventArgs to tell what row you're on instead of relying on SelectedRows:
Dim id As String = DataGridView1(e.RowIndex).Cells(2).Value