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")
Printable View
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")
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?
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 .
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.
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
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
that didnt work either, im stumped
Forget dimming it, just add it to your form from the toolbox.
i tried that, it doesnt work with the numeric up and down
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
that makes sense but i am gettin a syntax error with the As in the for next loop
what should i set c to?
Can you post your code? That code runs for me.
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
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
it works, thanks
This is because you're using 2002.
In 2003 you can use the "For X As Something..."
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