Solved

Changing a Tooltip Text

Posted on 2011-09-22
4
266 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 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

12 Experts available now in Live!

Get 1:1 Help Now