Results 1 to 8 of 8

Thread: [RESOLVED] ToolTipText in UserControl

  1. #1

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Resolved [RESOLVED] ToolTipText in UserControl

    I have an owner-drawn UserControl that I'm making, and I don't see a ToolTipText property?

    How would I go about adding one without adding a control on there like a label or whatever.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: ToolTipText in UserControl

    Tooltip property will "appear" when you add UserControl to any form.
    However, if UserControl contains any child control (label, textbox, etc) then you may assign individual ToolTips for those controls.
    So, at run time your user control may have multiple tooltips - one general and one for each child control.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: ToolTipText in UserControl

    As RhinoBull pointed out, the tooltip is assigned not by the usercontrol (uc). When a user adds your uc to their form/container, then the user can assign a tooltip. Think of your uc in terms of other VB controls, those controls do not assign tooltips, rather the user does when they add the control to the project.

    Though you can create your own api tooltip, it may be confusing to the user if they also assigned a tooltip. There are hacks around this, but again, wouldn't recommend it.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: ToolTipText in UserControl

    Oh man how did I miss that?

    I added it to my form and still didn't see a ToolTipText property but now I see it.

    Thanks.

  5. #5
    Junior Member
    Join Date
    Apr 2009
    Posts
    24

    Question Re: [RESOLVED] ToolTipText in UserControl

    Hi guys,

    I am trying to get the tooltiptext property as well...
    After read the posts, I still cannot get that property..

    What I am trying to do is showing a tooltip when a mousehover a label.
    I tried with SetToolTip ( not tooltiptext because i couldn't find it ) but nothing is shown when I hover the label. What have I done wrong?

  6. #6
    Hyperactive Member
    Join Date
    Mar 2009
    Posts
    264

    Re: [RESOLVED] ToolTipText in UserControl

    I know this is an old topic, but I was also searching the forums and could not find an answer on how to get the ToolTipText of the UserControl (as a designer of the UserControl).
    The following don't work, UserControl.ToolTipText or Me.ToolTipText.
    But if you need to access the ToolTipText on runtime, so what the user of the control set during designtime or on runtime, you can access the ToolTipText using UserControl.Extender.ToolTipText

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,915

    Re: [RESOLVED] ToolTipText in UserControl

    The ToolTipText (for a user control, UC) is one of the Extender Properties that you always get when you use this UC on a form. As such, it's not really meant to be used within the UC's code itself. If you did, you wouldn't know which instance of the UC's ToolTipText property you were talking about.

    So, if you have a UC on your form named "MyUc", you'd get to the ToolTipText property by: Debug.Print MyUc.ToolTipText

    As we see, we just use the actual name of the control as it appears on our form. From within the form's code (but not the UC's code), we've got direct access to all of these ToolTipText properties for all the controls on the form.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #8
    Hyperactive Member
    Join Date
    Mar 2009
    Posts
    264

    Re: [RESOLVED] ToolTipText in UserControl

    Quote Originally Posted by Elroy View Post
    If you did, you wouldn't know which instance of the UC's ToolTipText property you were talking about.
    What are you talking about? When developing a UserControl and I read the UserControl.Extender.ToolTipText from within the usercontrol, like the event UserControl_MouseMove() , I get the ToolTipText of that specific instance which is placed on the form. Even if I have a 100 of my UserControls on the same form, or even in a control array, UserControl.Extender.ToolTipText gives me the ToolTipText of that one instance and not random of any of the other instances places on a form.



    Quote Originally Posted by Elroy View Post
    So, if you have a UC on your form named "MyUc", you'd get to the ToolTipText property by: Debug.Print MyUc.ToolTipText
    Really? I would not have guessed that.......


    Quote Originally Posted by Elroy View Post
    As we see, we just use the actual name of the control as it appears on our form. From within the form's code (but not the UC's code), we've got direct access to all of these ToolTipText properties for all the controls on the form.
    Have you ever created your own usercontrol? If so, you would know that it is very handy to know what the user of your control has entered in certain properties from within your usercontrol, it's even basic needs, as without knowing the value of properties within your usercontrol, you can't really do anything. And in this case, I need to know from within my usercontrol what the user has entered as ToolTipText, and I want to know WHEN the user changes the value so I can do stuff with it. That's how you create a UserControl.

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