Tool tips

  • Thread starter Thread starter Helen Trim
  • Start date Start date
H

Helen Trim

I want to show a bit of data on a form as a tool tip text,
to avoid cluttering up the form. I am using SetToolTip
for a text box.

tipNotesMoved.SetToolTip(ShowPatient.txtNotesTracking,
strNotesMoved)

I want the data to change from patient to patient, and
according to MSDN, SetToolTip will allow this. To quote
MSDN:
Calling the SetToolTip method more than once
for a given control does not specify multiple ToolTip text
to display for a control but instead changes the current
ToolTip text for the control.

But what actually happens is that it shows correctly for
the first patient but then adds another tooltip for the
second. The data for the first patient pops up followed
by the data for the second patient.

Does anyone know how to clear a tool tip? I have used the
RemoveAll method but it does nothing. You still get
multiple tips appearing.

Thanks,
Helen
 
Helen,

Helen Trim said:
I want to show a bit of data on a form as a tool tip text,
to avoid cluttering up the form. I am using SetToolTip
for a text box.

tipNotesMoved.SetToolTip(ShowPatient.txtNotesTracking,
strNotesMoved)

I want the data to change from patient to patient, and
according to MSDN, SetToolTip will allow this. To quote
MSDN:
Calling the SetToolTip method more than once
for a given control does not specify multiple ToolTip text
to display for a control but instead changes the current
ToolTip text for the control.

But what actually happens is that it shows correctly for
the first patient but then adds another tooltip for the
second. The data for the first patient pops up followed
by the data for the second patient.

I am not able to reproduce this behavior (.NET 1.1 SP1, Windows XP
Professional SP2).
Does anyone know how to clear a tool tip? I have used the
RemoveAll method but it does nothing. You still get
multiple tips appearing.

You can remove a control's tooltip by setting it to an empty string:

\\\
Me.ToolTip1.SetToolTip(Me.TextBox1, "")
///
 
Thanks, but I had already tried that. Whatever I do, it
still adds more tooltips and won't clear them.

Oh well, back to the drawing board.

Thanks,
Helen
 
Helen,

Helen Trim said:
Thanks, but I had already tried that. Whatever I do, it
still adds more tooltips and won't clear them.

What Windows/.NET version are you using?
 
Helen,

Helen Trim said:
Windows 2000 & Windows 2003 ( both give same effect )
and .NET 1.1

Any ideas?

I feel sorry, I don't have any other ideas.

What you can do is trying to build a short but complete program that can be
used to reproduce the problem, upload it somewhere in a ZIP file and post a
link to it here. This would allow others to check if they can repro the
problem. I am curious if you are able reproduce the problem in a new
project with only a button control, a tooltip component and the code that is
necessary to change the tooltip's text.
 
Helen,

I find this a good idea from Herfried, however the best thing is to show
that sample project he tells about.

Than it is probably not even needed to make a zip file. When there is not so
much code than is only pasting in the added code (first in a notebook and
than back in the message) probably enough.

Just my thoughts,

Cor
 
Hello Cor and Herfried

Thanks for your help. You can recreate the problem by
starting a new windows application and adding a textbox,
label and button. Add this code to the button's click
event. Run it and type different things into the text box
and click the button. The label shows the tooltips
building up ona after the other.

Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim tipButton As New System.Windows.Forms.ToolTip

tipButton.RemoveAll()
tipButton.SetToolTip(Me.Label1, "")
tipButton.SetToolTip(Me.Label1, TextBox1.Text)

End Sub

Can you think of a way to solve this?

Thanks,
Helen
 
Hi Helen

The problem is that each time you enter the click event you create a new
tooltip. You then remove all from this new tooltip, which has no effect on
the tooltip you created the last time you entered the event. I would either
make it static and only create a new one if it is Nothing, or move the
declaration to module level.

HTH

Charles
 
So simple! Thanks, it works now.

Helen
-----Original Message-----
Hi Helen

The problem is that each time you enter the click event you create a new
tooltip. You then remove all from this new tooltip, which has no effect on
the tooltip you created the last time you entered the event. I would either
make it static and only create a new one if it is Nothing, or move the
declaration to module level.

HTH

Charles





.
 
Charles,

Your solution is right, however your explanation in my opinion not complete
(I tried it).

I have the idea that with *settooltip* every time there is an *add* of a
tooltipobject too a collection of tooltips and not *set* a reference to a
tooltip.

When showed it shows a video of all tooltips.

However I nowhere saw a *removetooltip*

Where the instruction should be *addTooltip* when what I saw is right.

Interesting.

:-)

Cor
 
Helen,

Helen Trim said:
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim tipButton As New System.Windows.Forms.ToolTip

tipButton.RemoveAll()
tipButton.SetToolTip(Me.Label1, "")
tipButton.SetToolTip(Me.Label1, TextBox1.Text)

End Sub

Can you think of a way to solve this?

Instead of creating a new instance of 'ToolTip' every time the button is
clicked, use always the /same/ instance. If you are using VS.NET, simply
place a tooltip component on your form at design time and use this component
throughout your code. Notice that it's not necessary to remove the tooltip
before setting it to a new text if you are using the same tooltip object.
The code

\\\
ToolTip1.SetToolTip(Me.Label1, TextBox1.Text)
///

should be sufficient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top