gpt4 book ai didi

vb.net - ContextMenuStrip 不显示附近的光标

转载 作者:行者123 更新时间:2023-12-01 08:33:19 25 4
gpt4 key购买 nike

当我在 datgridview 中右键单击一行时,我正在尝试创建一个显示上下文菜单的事件。

这是正在发生的问题的图片:

enter image description here

这是我目前使用的代码:

Private Sub dgvStudents_CellMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvStudents.CellMouseDown
Dim rowClicked As DataGridView.HitTestInfo = dgvStudents.HitTest(e.X, e.Y)
'Select Right Clicked Row if its not the header row
If e.Button = Windows.Forms.MouseButtons.Right AndAlso e.RowIndex > -1 Then
'Clear any currently sellected rows
dgvStudents.ClearSelection()
Me.dgvStudents.Rows(e.RowIndex).Selected = True
ContextMenuStrip1.Show(dgvStudents, Control.MousePosition)

End If
End Sub

P.S 屏幕截图没有显示我的光标 >.> 但它绝对没有与上下文菜单同步!

编辑:好的,我已经解决了,

我只是将 Control.MousePosition 替换为 MousePosition,它就起作用了!

最佳答案

这些都不适合我。让菜单在鼠标下弹出的解决方案是:

ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)

关于vb.net - ContextMenuStrip 不显示附近的光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15313734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com