Results 1 to 11 of 11

Thread: [RESOLVED] [2008] noob question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Resolved [RESOLVED] [2008] noob question

    how do you add a tooltip on mouseover of a control? I can't seem to find it. VB6 had a property for it

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] noob question

    I never knew if I was doing this right but this is the only way I ever managed to make it work - Drag n drop a tooltip component from the toolbox onto your form. Now in your form load event or something use the SetTooltip method like this:
    vb Code:
    1. ToolTip1.SetToolTip(Button1, "test tooltip")
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] noob question

    The ToolTip is a provider component, which means that it appears to extend the functionality of other design-time components. When you add a ToolTip component to a form, all the controls on that form get a new property named "ToolTip on ToolTip1" or the like. You can set the text to be displayed in the tool tip there for that control. Now, the control doesn't actually get a new property. It just seems like it at design-time, courtesy of the IExtenderProvider interface that the ToolTip implements. The actual code that gets created simply calls the SetToolTip method, much as Chris has shown can be done manually. Try setting some tool tip text for a control and then opening the designer code file to see for yourself.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] noob question

    Yeah I noticed that 'extra property' on the controls but I didnt realise it was specific to each control... I dunno I didnt really take much notice of it really but I guess it makes sense that you wouldnt have a global property displayed in a control's property box in the designer Thanks for clarifying.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: [2008] noob question

    im sorry, jmcilhinney I couldn't really follow what you were saying because of how advanced it is.. can you by chance show code examples with what your talking about?

    thank you for your responses everyone, much appreciated

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: [2008] noob question

    for example... why I double click the tooltip control it opens a grey box under the form design and adds it there... does this mean I can use it on any form?


    when it comes to adding controls im so used to it all going right onto the form, because I used to and started programming in vb6

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] noob question

    It's pretty simple stuff.
    When you add a ToolTip component to a form, all the controls on that form get a new property named "ToolTip on ToolTip1" or the like.
    Did you look to see whether your controls do indeed have that extra property after you added the ToolTip?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: [2008] noob question

    haha sorry for the stupidity I guess I was to busy concentrating on all the other stuff you said.. however I did not check I will in a moment... I did however add this line of code to the control_mousehover() procedure


    vb.net Code:
    1. ToolTip.SetToolTip(control:=picItem, caption:="Double-Click to add a picture of the item noted.")


    if I use the method your saying do I also just put that in the mousehover procedure?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: [2008] noob question

    you were right jmcilhinney the controls on the form obtained the property tooltip on <controlname> however I can only set it in the property window, and not in the code.. which is what I originally thought you meant.. however, is there a way to add it in code... but it's probably not even needed because the property takes care of it when you hover over the control

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] noob question

    Go back to post #3. Read it. Do what it says. That's all you need.

    The only reason you would call SetToolTip explicitly is if you needed to change the text to be displayed in the tool tip to something different to what you set it to at design time. This can certainly happen, although more often than not the tool tip text for a control will remain the same throughout the life of the app.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Location
    Toledo, OH
    Posts
    785

    Re: [2008] noob question

    correct... I appreciate your help.

    as for post #3 it makes ALOT more sense now that I put the control to use and tested it in both ways provided in this thread.. thank you to the both of you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width