开发者

return get datagridview cell value in vb.net

开发者 https://www.devze.com 2022-12-23 03:03 出处:网络
Im trying to return the value contain开发者_开发百科ed in a datagridview cell upon clicking on the cell. can anyone please show me how to do this using vb.net?thanks Check this sample code. The key is

Im trying to return the value contain开发者_开发百科ed in a datagridview cell upon clicking on the cell. can anyone please show me how to do this using vb.net?thanks


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


You can call from a button

Dim y As String = DataGridView1.CurrentCell.Value

If IsDBNull(y) Then

Else

TextBox1.Text = y

End If
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号