Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

return get datagridview cell value in vb.net

Tags:

vb.net

Im trying to return the value contained in a datagridview cell upon clicking on the cell. can anyone please show me how to do this using vb.net?thanks

like image 833
Selom Avatar asked Mar 22 '26 03:03

Selom


1 Answers

Check this sample code. The key is to use the event's DataGridViewCellEventArgs parameter to find the clicked cell's RowIndex and ColumnIndex.

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, _
                                    ByVal e As DataGridViewCellEventArgs) _
                                    Handles DataGridView1.CellClick
    MsgBox(DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
End Sub
like image 160
M.A. Hanin Avatar answered Mar 24 '26 16:03

M.A. Hanin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!