How to handle mouse events?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shariquekhan
    New Member
    • Jun 2010
    • 8

    #1

    How to handle mouse events?

    Hi, 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
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    What do you mean by the label...
    Is it a tooltip that you're saying

    Comment

    • shariquekhan
      New Member
      • Jun 2010
      • 8

      #3
      Originally posted by ThatThatGuy
      What do you mean by the label...
      Is it a tooltip that you're saying
      That is not a tool tip. But I want to use as a tool tip. I want to show some description in status bar label. I have menustrip in my application and I want that when I move mouse on menu option. It shows description in status bar label. For Example I have open tool strip item in menu strip and when I move mouse on "open" option it shows text "Open Files" in status bar label. Give me an idea how to use Mouse Enter/Move/Leave events. I used mouse move & mouse Enter events it shows text in a label control but when I take away my mouse from "open" option, it still shows the open description. Any Idea how to use Mouse leave event or What mouse leave event can do? Here is my code. Take a look and tell me what's the problem

      private void openToolStripMe nuItem_MouseEnt er(object sender, EventArgs e)
      {
      label1.Text = "Open files";

      }


      private void openToolStripMe nuItem_MouseLea ve(object sender, EventArgs e)
      {
      label1.Text = "";

      }

      Comment

      • shariquekhan
        New Member
        • Jun 2010
        • 8

        #4
        Hey above code is works fine for me. I am happy. I really don't know whats the problem at that time. But Now above code works fine for me

        Comment

        • ThatThatGuy
          Recognized Expert Contributor
          • Jul 2009
          • 453

          #5
          Originally posted by shariquekhan
          That is not a tool tip. But I want to use as a tool tip. I want to show some description in status bar label. I have menustrip in my application and I want that when I move mouse on menu option. It shows description in status bar label. For Example I have open tool strip item in menu strip and when I move mouse on "open" option it shows text "Open Files" in status bar label. Give me an idea how to use Mouse Enter/Move/Leave events. I used mouse move & mouse Enter events it shows text in a label control but when I take away my mouse from "open" option, it still shows the open description. Any Idea how to use Mouse leave event or What mouse leave event can do? Here is my code. Take a look and tell me what's the problem

          private void openToolStripMe nuItem_MouseEnt er(object sender, EventArgs e)
          {
          label1.Text = "Open files";

          }


          private void openToolStripMe nuItem_MouseLea ve(object sender, EventArgs e)
          {
          label1.Text = "";

          }
          Them use MouseMove event instead of MouseEnter

          Comment

          Working...