954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Close Context Menu When Mouse Leaves

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();
     }
}
skybomb0
Newbie Poster
11 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Handle the MouseLeave event of ContentMenuStrip.

private void contextMenuStrip1_MouseLeave(object sender, EventArgs e)
{
   contextMenuStrip1.Hide();
}
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

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.

skybomb0
Newbie Poster
11 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: