|
-
Jul 20th, 2004, 12:35 AM
#1
Thread Starter
New Member
tool tips [Resolved]
how do you display a tool tip for a numberic up and down?
this is how i have it now but it doesnt work
VB Code:
Dim toolTip As New ToolTip
toolTip.ShowAlways = True
toolTip.SetToolTip(Me.nudRate, "Rate")
toolTip.SetToolTip(Me.nudYears, "Years")
Last edited by salating; Jul 20th, 2004 at 02:47 PM.
-
Jul 20th, 2004, 06:53 AM
#2
Frenzied Member
Try adding a tooltip control from the toolbox.
Don't use the classname (Tooltip) for the name of the control.
Where do you set the tooltip values?
-
Jul 20th, 2004, 07:59 AM
#3
Sleep mode
Add ToolTip to the form , click on the control you want to show that tooltip on , set the ToolTip on .... to show the message to the user .
-
Jul 20th, 2004, 09:24 AM
#4
Frenzied Member
I wonder if it's possible to do this programmatically. MSDN says so, under the topic "Setting ToolTips for Controls on a Windows Form", but it does not seem to work.
-
Jul 20th, 2004, 09:28 AM
#5
Thread Starter
New Member
i have my tool tips loaded in the form
VB Code:
Private Sub frmInvestment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim toolTip As New ToolTip
toolTip.ShowAlways = True
toolTip.SetToolTip(Me.txtPrinciple, "Principle")
toolTip.SetToolTip(Me.nudRate, "Rate")
toolTip.SetToolTip(Me.nudYears, "Years")
toolTip.SetToolTip(Me.cmbPeriods, "Periods")
toolTip.SetToolTip(Me.txtInvestment, "Investment Amount")
toolTip.SetToolTip(Me.btnReset, "Reset Values")
toolTip.SetToolTip(Me.btnCalculate, "Calculate Investment")
toolTip.SetToolTip(Me.btnPrint, "Print Investment Information")
toolTip.SetToolTip(Me.btnExit, "Exit Program")
End Sub
-
Jul 20th, 2004, 09:41 AM
#6
I think your problem is that you use Dim toolTip As New ToolTip inside your sub.
The toolTip variable goes out of scope when the sub ends, and therefore doesn't exists anymore.
Try putting it outside the sub, in the Declarations part.
VB Code:
Dim toolTip As New ToolTip
Private Sub frmInvestment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
toolTip.ShowAlways = True
toolTip.SetToolTip(Me.txtPrinciple, "Principle")
toolTip.SetToolTip(Me.nudRate, "Rate")
toolTip.SetToolTip(Me.nudYears, "Years")
toolTip.SetToolTip(Me.cmbPeriods, "Periods")
toolTip.SetToolTip(Me.txtInvestment, "Investment Amount")
toolTip.SetToolTip(Me.btnReset, "Reset Values")
toolTip.SetToolTip(Me.btnCalculate, "Calculate Investment")
toolTip.SetToolTip(Me.btnPrint, "Print Investment Information")
toolTip.SetToolTip(Me.btnExit, "Exit Program")
End Sub
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Jul 20th, 2004, 09:49 AM
#7
Thread Starter
New Member
that didnt work either, im stumped
-
Jul 20th, 2004, 10:18 AM
#8
Frenzied Member
Forget dimming it, just add it to your form from the toolbox.
-
Jul 20th, 2004, 10:39 AM
#9
Thread Starter
New Member
i tried that, it doesnt work with the numeric up and down
-
Jul 20th, 2004, 10:54 AM
#10
Frenzied Member
Interesting. The NumericUpDown is actually built out of two seperate controls. Assigning the tool tip to the outer control does not work. You have to iterate through the controls and set the tool tip for each one.
VB Code:
ToolTip1.SetToolTip(Me.TextBox1, "Text Box") ' works
ToolTip2.SetToolTip(Me.NumericUpDown1, "Numeric up down") ' doesn't work
For Each c As Control In NumericUpDown1.Controls
MessageBox.Show(c.ToString)
ToolTip2.SetToolTip(c, "This works")
Next
-
Jul 20th, 2004, 01:54 PM
#11
Thread Starter
New Member
that makes sense but i am gettin a syntax error with the As in the for next loop
what should i set c to?
-
Jul 20th, 2004, 02:02 PM
#12
Frenzied Member
Can you post your code? That code runs for me.
-
Jul 20th, 2004, 02:21 PM
#13
Thread Starter
New Member
i have to declare c as something
but i get a syntax error with the As
VB Code:
Private Sub frmInvestment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create the ToolTip and associate with the Form container.
Dim toolTip As New ToolTip()
' Force the ToolTip text to be displayed whether or not the form is active.
toolTip.ShowAlways = True
' Set up the ToolTip text for the Buttons, Text Boxes, Numeric Up and Down and Combo Box.
toolTip.SetToolTip(Me.txtPrinciple, "Principle")
toolTip.SetToolTip(Me.nudRate, "Rate")
toolTip.SetToolTip(Me.nudYears, "Years")
toolTip.SetToolTip(Me.cmbPeriods, "Periods")
toolTip.SetToolTip(Me.txtInvestment, "Investment Amount")
toolTip.SetToolTip(Me.btnReset, "Reset Values")
toolTip.SetToolTip(Me.btnCalculate, "Calculate Investment")
toolTip.SetToolTip(Me.btnPrint, "Print Investment Information")
toolTip.SetToolTip(Me.btnExit, "Exit Program")
For Each c As Control In nudRate.Controls
MessageBox.Show(c.ToString)
toolTip.SetToolTip(c, "This works")
Next
End Sub
-
Jul 20th, 2004, 02:34 PM
#14
Frenzied Member
hmm - I have no idea why you get a syntax error. I don't. The code could be rewritten like this, but i don't see why that would make a difference
VB Code:
Dim c As Control
For Each c In NumericUpDown1.Controls
MessageBox.Show(c.ToString)
ToolTip2.SetToolTip(c, "This works")
Next
-
Jul 20th, 2004, 02:46 PM
#15
Thread Starter
New Member
-
Jul 20th, 2004, 03:15 PM
#16
This is because you're using 2002.
In 2003 you can use the "For X As Something..."
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Jul 20th, 2004, 05:43 PM
#17
Thread Starter
New Member
i use 2003 at home, i was at work and we have 2002
oh well, i got it working, i am suprised i had to do it that way to get it to work
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
|