I have a ContextMenuStrip that I am showing programmatically in response to a button being clicked. Everything works as expected, except that the Items in the menu do not respond to being moused over. Whether the mouse button is up or down, mousing over the menu has no visible effect, and releasing the mouse button does not select an Item, as expected. Performing a full click on an Item does still activate the Item, however.
Here's my code for showing the ContextMenuStrip:
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
MyBase.OnMouseDown(e)
If Enabled Then
m_MouseDown = True
If m_State > ButtonState.MousePressed Then
m_State = ButtonState.MousePressed
End If
Invalidate()
If DropDown IsNot Nothing AndAlso DropDown.Items.Count > 0 Then
If ShowMenu Then
ShowMenu = False
ElseIf arrowRect.Contains(PointToClient(MousePosition)) Then
ShowMenu = True
m_MouseHeldWhileOpened = True
DropDown.Capture = True
End If
End If
End If
End Sub
Protected Property ShowMenu() As Boolean
Get
Return m_showMenu
End Get
Set(ByVal value As Boolean)
If value <> m_showMenu Then
m_ShowMenu = value
If m_ShowMenu Then
m_DropDown.Show(Me, GetDropDownSpawnPoint, DropDownDirection)
m_State = ButtonState.MenuUp
If m_DropDown.ClientRectangle.Contains(PointToScreen(MousePosition)) Then
m_DropDown.Capture = True
End If
Else
m_DropDown.Close()
ElevateState()
End If
End If
End Set
End Property
I have tried a number of different ideas to get the menu to respond correctly, some of which attempts are still evident in the code here. If any help would be forthcoming, it would be greatly appreciated - nobody else on Google seems to have experienced this problem.
Thank you in advance for any help you can offer.