How do I create a label when the mouse over a button? RRS feed

  • Question

  • When a mouse moves over a button I want to be able to have a label appear.

    When I right click the right mouse I should have a menu list of choices which appear and can be selected from.

    How do I do that in beta 2?

    I had a build that had been compiled and working using beta 1 with everything that I need for the label.

    It does not seem to matter where I look I still seem unable to find a way to get the same code working in beta 2 with the new components I have created in beta 2.

    Michael J. Dyrnaes
    Monday, June 13, 2005 7:26 PM


All replies

  • Do you mean a context menu?

    Drag a button onto your form and name it Button1
    Drag a context menu onto your form and name it ContextMenuStrip1
    Add a couple of menu items to the ContextMenuStrip1 in the designer.
    To handle the "right click" event, can be handled instead by setting the button's "ContextMenuStrip" property to ContextMenuStrip1 (your context menu strip instance)
    Alternatively, the following code will show the menu strip directly to the right of the button and aligned with the top of the button.

    Sub Button1_MouseHover(ByVal sender As System.Object, _
               ByVal e As System.EventArgs) Handles Button1.MouseHover  
    .ContextMenuStrip1.Show(Button1, New Point(Button1.Width, 0))
    End Sub


    Tuesday, June 14, 2005 4:15 AM
  • I had done all that in beta one when I originally developed it and it still does not work in beta 2 now.

    What about the label that is supposed appear everytime the mouse is over the button?



    Thursday, June 16, 2005 4:26 PM
  • That code does work in Beta 2. If it doesn't work for you, you may have other problems. For the "label that is supposed to appear everytime the mouse is over the button" you are talking about a tooltip.  To get this effect, drag a ToolTip control onto the form.  Optionally, set the ToopTip icon to "Info" and the ToolTipTitle to something like "Testing".  After you've done this, select the button you want a tooltip to appear on and change the "ToolTip on toolTip1" property to "Testing tooltips" (or whatever you want obviously).

    Run your project and you should get the effect you wanted with a little more functionality than you had in VS.NET 2003.   
    Friday, June 17, 2005 3:04 AM
  • With some work I managed to get tooltip working in beta 2 but I still have not been able to get the contectmenustrip working in beta 2 yet.
    Friday, June 17, 2005 3:53 AM
  • Have you tried creating any context menu's for something other than a button?  For instance, try using one on a PictureBox control.   

    Friday, June 17, 2005 4:01 AM
  • No, all that I need it for is for the button.

    This morning when I selected BUILD the context menu sort of works ... There is some functional confusion between two buttons.  One button when I click it does both functions at the same time.  The other button does nothing.


    Friday, June 17, 2005 7:18 PM
  • This now seems to be working.

    Friday, June 17, 2005 8:06 PM