Solved

Changing a Tooltip Text

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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