Wine Too
Wine Too

Reputation: 4655

Get datagridview selected row position

I have to open a dialog from datagridview selected row which may be selected by code, by mouse or by keyboard in the position which depends of selected row location.

I get selected row index:

Dim srow As Integer = DataGridView1.CurrentRow.Index

How to easiest get location (XY point) of that selected row?

Upvotes: 0

Views: 7836

Answers (1)

ømi
ømi

Reputation: 521

do the code on datagridview cell mouse click event so you will get exact location

Private Sub dgvCust_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvCust.CellMouseClick
    Label1.Text = "X." & e.X & vbCrLf & "Y." & e.Y
End Sub

Upvotes: 2

Related Questions