Results 1 to 17 of 17

Thread: tool tips [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10

    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:
    1. Dim toolTip As New ToolTip
    2. toolTip.ShowAlways = True
    3.  
    4. toolTip.SetToolTip(Me.nudRate, "Rate")
    5. toolTip.SetToolTip(Me.nudYears, "Years")
    Last edited by salating; Jul 20th, 2004 at 02:47 PM.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    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?

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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 .

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    i have my tool tips loaded in the form

    VB Code:
    1. Private Sub frmInvestment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.  
    3.         Dim toolTip As New ToolTip
    4.  
    5.         toolTip.ShowAlways = True
    6.  
    7.         toolTip.SetToolTip(Me.txtPrinciple, "Principle")
    8.         toolTip.SetToolTip(Me.nudRate, "Rate")
    9.         toolTip.SetToolTip(Me.nudYears, "Years")
    10.         toolTip.SetToolTip(Me.cmbPeriods, "Periods")
    11.         toolTip.SetToolTip(Me.txtInvestment, "Investment Amount")
    12.         toolTip.SetToolTip(Me.btnReset, "Reset Values")
    13.         toolTip.SetToolTip(Me.btnCalculate, "Calculate Investment")
    14.         toolTip.SetToolTip(Me.btnPrint, "Print Investment Information")        
    15.         toolTip.SetToolTip(Me.btnExit, "Exit Program")    
    16. End Sub

  6. #6
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    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:
    1. Dim toolTip As New ToolTip
    2.  
    3. Private Sub frmInvestment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.  
    5.  
    6.         toolTip.ShowAlways = True
    7.  
    8.         toolTip.SetToolTip(Me.txtPrinciple, "Principle")
    9.         toolTip.SetToolTip(Me.nudRate, "Rate")
    10.         toolTip.SetToolTip(Me.nudYears, "Years")
    11.         toolTip.SetToolTip(Me.cmbPeriods, "Periods")
    12.         toolTip.SetToolTip(Me.txtInvestment, "Investment Amount")
    13.         toolTip.SetToolTip(Me.btnReset, "Reset Values")
    14.         toolTip.SetToolTip(Me.btnCalculate, "Calculate Investment")
    15.         toolTip.SetToolTip(Me.btnPrint, "Print Investment Information")        
    16.         toolTip.SetToolTip(Me.btnExit, "Exit Program")    
    17. End Sub
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    that didnt work either, im stumped

  8. #8
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Forget dimming it, just add it to your form from the toolbox.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    i tried that, it doesnt work with the numeric up and down

  10. #10
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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:
    1. ToolTip1.SetToolTip(Me.TextBox1, "Text Box") ' works
    2.         ToolTip2.SetToolTip(Me.NumericUpDown1, "Numeric up down") ' doesn't work
    3.  
    4.         For Each c As Control In NumericUpDown1.Controls
    5.             MessageBox.Show(c.ToString)
    6.             ToolTip2.SetToolTip(c, "This works")
    7.         Next

  11. #11

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    that makes sense but i am gettin a syntax error with the As in the for next loop

    what should i set c to?

  12. #12
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Can you post your code? That code runs for me.

  13. #13

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    i have to declare c as something

    but i get a syntax error with the As


    VB Code:
    1. Private Sub frmInvestment_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.  
    3.         ' Create the ToolTip and associate with the Form container.
    4.         Dim toolTip As New ToolTip()
    5.  
    6.  
    7.         ' Force the ToolTip text to be displayed whether or not the form is active.
    8.         toolTip.ShowAlways = True
    9.  
    10.  
    11.         ' Set up the ToolTip text for the Buttons, Text Boxes, Numeric Up and Down and Combo Box.
    12.         toolTip.SetToolTip(Me.txtPrinciple, "Principle")
    13.         toolTip.SetToolTip(Me.nudRate, "Rate")
    14.         toolTip.SetToolTip(Me.nudYears, "Years")        
    15.         toolTip.SetToolTip(Me.cmbPeriods, "Periods")
    16.         toolTip.SetToolTip(Me.txtInvestment, "Investment Amount")
    17.         toolTip.SetToolTip(Me.btnReset, "Reset Values")
    18.         toolTip.SetToolTip(Me.btnCalculate, "Calculate Investment")
    19.         toolTip.SetToolTip(Me.btnPrint, "Print Investment Information")
    20.         toolTip.SetToolTip(Me.btnExit, "Exit Program")
    21.  
    22.         For Each c As Control In nudRate.Controls
    23.             MessageBox.Show(c.ToString)
    24.             toolTip.SetToolTip(c, "This works")
    25.         Next
    26.  
    27.     End Sub

  14. #14
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    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:
    1. Dim c As Control
    2.         For Each c In NumericUpDown1.Controls
    3.             MessageBox.Show(c.ToString)
    4.             ToolTip2.SetToolTip(c, "This works")
    5.         Next

  15. #15

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    it works, thanks

  16. #16
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    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...

  17. #17

    Thread Starter
    New Member
    Join Date
    Jul 2004
    Posts
    10
    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
  •  



Click Here to Expand Forum to Full Width