vb.net 获取datagridview选中的行位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14657243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get datagridview selected row position
提问by Wine Too
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.
我必须从 datagridview 选择的行中打开一个对话框,该对话框可以通过代码、鼠标或键盘在取决于所选行位置的位置进行选择。
I get selected row index:
我得到选定的行索引:
Dim srow As Integer = DataGridView1.CurrentRow.Index
How to easiest get location (XY point) of that selected row?
如何最简单地获取所选行的位置(XY 点)?
回答by Dandy
do the code on datagridview cell mouse click event so you will get exact location
在 datagridview 单元格鼠标单击事件上执行代码,以便您获得确切位置
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

