|
-
Aug 7th, 2008, 06:50 PM
#1
Thread Starter
Fanatic Member
[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
-
Aug 7th, 2008, 06:54 PM
#2
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:
ToolTip1.SetToolTip(Button1, "test tooltip")
-
Aug 7th, 2008, 07:00 PM
#3
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.
-
Aug 7th, 2008, 07:04 PM
#4
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.
-
Aug 7th, 2008, 08:31 PM
#5
Thread Starter
Fanatic Member
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
-
Aug 7th, 2008, 08:33 PM
#6
Thread Starter
Fanatic Member
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
-
Aug 7th, 2008, 08:39 PM
#7
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?
-
Aug 7th, 2008, 08:44 PM
#8
Thread Starter
Fanatic Member
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:
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?
-
Aug 7th, 2008, 08:48 PM
#9
Thread Starter
Fanatic Member
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
-
Aug 7th, 2008, 08:59 PM
#10
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.
-
Aug 7th, 2008, 09:04 PM
#11
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|