I am using windows forms. I have a problem in handling mouse events. In my application there is menu bar on top. In menu bar I have several toolstripmenu items. I want that when toolstripmenu item is highlighted, it shows some description in label. I am totally confused. What event I used to handle this problem. I used mouse enter, mouse move & mouse leave event but when mouse enters in the area of any menu item, its alright. The label shows some description when mouse enters or mouse move on the item. But when I move mouse on other area of form. The label remain shows the description about an item. I want that when mouse leaves the area of toolstripmenu item, the label goes blank. Help me to solve this problem
I use it for toolstripmenuitem. Mouse Enter & Mouse move event works fine but the main problem in mouse Leave event. When I move mouse on "open" option it shows description in label but when my mouse leave this option or leave the visible part of this option. The label description is same. Actually mouse leave event fires when any other control is in the focus after leaving "open" option. For Example I have menustrip & in menustrip I have several options. For Example First option is "Open" & I want that When mouse enters in visible part of "open" o开发者_JS百科ption its shows description in status bar lable "Open Files" & when my Mouse leave the visible part of "open" option, statusbarlabel goes blank but problem is that I can't understand properly when mouse leave event fires. Thanks for replying this question.
Here is my code. Take a look & tell me whats the problem?
private void openToolStripMenuItem_MouseEnter(object sender, EventArgs e)
{
label1.Text = "Open files";
}
private void openToolStripMenuItem_MouseLeave(object sender, EventArgs e)
{
label1.Text = "";
}
Use the MouseLeave event in your menuStrip and set the label text to "".
or use the same mouse event in your form and set the label text to " "..
I mean :
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
label1.Text = "";
}
you can use this solution if you want to show a text when the mouse is on the form.
Use the MouseLeave
Event. In the same way you did MouseOver
, when you catch a MouseLeave
of your menu item, change the Label's Text property to "" (i.e. blank)
精彩评论