Solved

Changing a Tooltip Text

Posted on 2011-09-22
4
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

729 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