Solved

Changing a Tooltip Text

Posted on 2011-09-22
4
270 Views
Last Modified: 2012-05-12
I'm using VB.Net 2010 (Professional)

I have a row of buttons that allow the user to add notes at various places in my app.  The user clicks the button, a dialog box opens allowing the user to type in the note after which he'll click the OK button, etc.  
Rather than have the user click the button to view an existing note, I was putting the text of the note in the button's tooltip.  However I discovered if the user changes the note text, but the original tooltip and the revised tooltip appear during a subsequent hover.

So my question is, how do I change a tooltip's text, rather than create a new tooltip every time the user edits the note text?

My code (sort of):
Private Sub btnNote1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNote1.Click
    Dim ttMain As New ToolTip()
    ttMain.AutoPopDelay = 5000
    ttMain.InitialDelay = 1000
    ttMain.ReshowDelay = 500
    ttMain.ShowAlways = True

    dlgNote.Note = m_Notes(1)
    Select Case dlgNote.ShowDialog()
        Case Windows.Forms.DialogResult.OK
            mm_Notes(1) = dlgNote.Note
            ttMain.SetToolTip(sender, dlgNote.Note)
        Case Windows.Forms.DialogResult.Cancel
            m_Notes(1) = m_ObsNotes.Plumb(nIndex)
        Case Windows.Forms.DialogResult.Ignore
            m_Notes(1) = ""
            ttMain.SetToolTip(sender, "")
    End Select
End Sub

Open in new window

0
Comment
Question by:Clif
4 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 36581504
when saving the note from your dialog, replace the old note with the new note rather than appending the new note to the old one.
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36581573
Remove the old tooltip before changing it to a new one:

ttMain.SetToolTip(sender, "")
ttMain.SetToolTip(sender, dlgNote.Note)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 36581936
Don't use a new ToolTip for every single button though!  Just declare it at Class(Form) level and re-use the same instance for all the controls.
0
 
LVL 10

Author Closing Comment

by:Clif
ID: 36582047
That did it.  Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now