Basically what I have is a Datagridview that I want to show a context menu strip when it is right clicked. But only when right clicked on a cell, not on the header or a blank part of the datagridview control. I also want it to select the entire row when right clicked. I have the row selection working, and the context menu strip opens but it open way away from the mouse as per the screenshot.
Private Sub DgvDelays_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DgvDelays.CellMouseDown
Dim rowClicked As DataGridView.HitTestInfo = DgvDelays.HitTest(e.X, e.Y)
If e.Button = Windows.Forms.MouseButtons.Right AndAlso e.RowIndex > -1 Then
DgvDelays.ClearSelection()
Me.DgvDelays.Rows(e.RowIndex).Selected = True
CmsRightClick.Show(DgvDelays, New System.Drawing.Point(Windows.Forms.Cursor.Position))
End If
End Sub
Image[
^]