Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing tooltips...

Status
Not open for further replies.

FederalProgrammer

Programmer
Jul 2, 2003
318
CA
It sounds simple enough... I don't know why I can't get it to work....
To put a tooltip on a control, following is true:

dim tt as new tooltip
tt.settooltip(control, tooltipText)

Now, how can I remove this tooltipText??

for the curious ones, I have a toolbar that is activated in my MDI-container based on what tool is launched and used. Each tool will use the toolbar based on its needs. So an openFolder icon may mean create a new folder in one tool, while in the other, it means, i don't know, Open a bunch of graphs. So as you see, each tool will have its own tooltip to display for each button. And that's why I have to add/remove the tooltips as the tools in mdi-container are selected/deselected...

Any help is much apreciated!
 
nop!
Apparently "NULL" is not a valid name for a control ;)
And I did make tt global....
I've tried basically all the possibilities w/ tt.Settooltip
 
I don't know. You may have to use a tt.RemoveAll() and then build it back up.
 
this works

Code:
 tt.RemoveAll()
 tt = Nothing

Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
where did you declare the tooltip??

because i tried my code and it worked perfect

copy paste this and try

Code:
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim tt As New ToolTip

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(184, 104)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TextBox1"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(80, 176)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "Button1"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(168, 176)
        Me.Button2.Name = "Button2"
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "Button2"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.TextBox1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tt.SetToolTip(TextBox1, "ikk")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        tt.RemoveAll()
        tt = Nothing
        'tt.Dispose()

    End Sub
End Class


Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
and with this code it works even better


Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        tt.SetToolTip(TextBox1, "ikk")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tt.SetToolTip(TextBox1, "ikk")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        tt.SetToolTip(TextBox1, "")
        'tt.RemoveAll()
        'tt = Nothing
        'tt.Dispose()

    End Sub

Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
<<<<<<<<<<<<
tt.RemoveAll()
tt = Nothing
>>>>>>>>>>>>>>

I think this was the trick...
Thanx a million...

Hay, why didn't I see Belgium in Euro 2004?!! they've got a good team goin' on there?

Any ways, thanx for the tip ;)
 
I think my second suggestion will work better because the first one you need to do

dim tt as new tooltip

everytime after the tt= nothing


Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
once again, thanx for the effort,
but I realy need to set tt to a new tooltip everytime a new text is to be displayed on my toolbar (it worn't work without re-initiating the tooltip)....
Well, the good news is it's working whichever way...
cheers!
 
now i think you are missing the point of the whole tooltip component, but if it works its fine by me.

Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
I'm not sure where we disagree... The design with which I'm working has the following pattern:

1) A main Form
2) Toolbar form (you can think of this as the icons displayed on top of any normal microsoft document)
3) Many little tools that are childrent to the main form in 1

Now, the toolbar form (2) is a singleton object (there's only one instance of it lying around). There are some buttons on this toolbar form.
Each little tool (forms of the 3rd kind) has an event handler that handles the click event of the buttons of toolbar. (this is done through an interface. each little tool implements an interface providing an event handler, a tooltip text for each button, and some other junk)
The toolbar form then associates the text of a single tooltip to the passed in value by converting each little tool into the interface type.

I'm not sure why you think I am missing the point of tooltips; Please do tell me where you think i'm wrong...
cheers!
 
you see tooltip is suppossed to extend the other controls

windows forms does it like this

Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)

after this all the controls in me.components will have the tooltip property added to them thats why its called an extender (or something like that ) so you only have to have on tooltip control for the whole page and then they all have the tooltip property in wich you can set the text it has to display when the cursor passes over it.

in the ide the property becomes something like

tooltip on tooltip1

so you get something like this

BTW never mind the

MS said:
'Do not modify it using the code editor.

I modify it all the time


Code:
Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.SuspendLayout()
        '
        'TextBox1
        '
        Me.TextBox1.Location = New System.Drawing.Point(80, 64)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 0
        Me.TextBox1.Text = "TextBox1"
        Me.ToolTip1.SetToolTip(Me.TextBox1, "tooltip1ikk")

Christiaan Baes
Belgium

What a wonderfull world - Louis armstrong
 
Right...
I totally agree w/ you... and usually in simple cases when my tools are all created in design time I pretty much do a similar thing....
What about the case when the tools are not created @ design time? You see, I only have a single instance of a button call it btnX.
Now, what if I tell you that btnX will display a "hello message" on a click when one condition is true and "displayes goodbye" in another condition? In this case, the same tooltip won't do. will it?
I need to be able to set a text on this button based on what condition is true... I know u're gonna get into the argument of this is a bad interface; however this is just an example... this is not the case with which i'm dealing...
Any ways, I like a constructive argument like this... do let me know if you think I'm wrong....
cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top