[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Changing a Tooltip Text

Posted on 2011-09-22
4
Medium Priority
?
295 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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
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 anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month17 days, 15 hours left to enroll

830 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