I am trying to create my own menu (and practice a little c#) and I am almost done. I have the menu and the context menu that will be shown created. I also have the context menu showing at the correct time.
My problem comes when the menu disappears when you try to move your mouse over it. Only about 75% of the time though. The code below is the only spot where the context menu is hidden. I have uploaded the full project here.

private void this_MouseEnter(object sender, EventArgs e)
{
     System.Diagnostics.Debug.WriteLine("Enter");
     isOverContextMenu = true;
}
		
private void this_MouseLeave(object sender, EventArgs e)
{
     if(myState == "show" && !isOverContextMenuItem)
     {
          System.Diagnostics.Debug.WriteLine("Exit");
          isOverContextMenu = false;
          HIDE();
     }
}

Recommended Answers

All 2 Replies

Handle the MouseLeave event of ContentMenuStrip.

private void contextMenuStrip1_MouseLeave(object sender, EventArgs e)
{
   contextMenuStrip1.Hide();
}

I don't have a contextMenuStrip1 variable so I'm not sure exactly what object you are referring to, but have managed to get most of the closing to work. The only problem I am having now is after you click on the menu item, move your mouse over the menu, and then move the mouse back over the menu item you clicked, the context menu should stay open. How would I go about this?

I have updated my project at the above link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.