ToolTip in TextBox

A

alberto

I have in a form a TextBox where the user edit a single word. The user,
as long is editing a single word, can't type a space so I handle the
keyPress event.

I'd like also show a text (like the tooltip one) explaining what's
happening to the user but I don't know how to show a tooltip. I need to
show it inmediatly when the user types (and only in this case) a separator.

Could you tell me how to do it? Thank you very much.
 
E

eric

I have in a form a TextBox where the user edit a single word. The user,
as long is editing a single word, can't type a space so I handle the
keyPress event.

I'd like also show a text (like the tooltip one) explaining what's
happening to the user but I don't know how to show a tooltip. I need to
show it inmediatly when the user types (and only in this case) a separator.

Could you tell me how to do it? Thank you very much.

This example in the msdn seems quite good and might help you :
http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip(VS.80).aspx
In your case, just display the tooltip in the keydown event when the
user enter a separator.
 
A

Alberto

I'm doing this:

if (e.KeyChar == ' ')
{
e.Handled = true;
toolTip.SetToolTip(txt, ".......");
}
else
toolTip.SetToolTip(txt, "");

but it doesn't work fine. I need that the message be shown just when the
user press the bar space and not when the mouse pointer is over the textbox.

El 29/01/2010 13:55, eric escribió:
 
P

Peter Duniho

Alberto said:
I'm doing this:

if (e.KeyChar == ' ')
{
e.Handled = true;
toolTip.SetToolTip(txt, ".......");
}
else
toolTip.SetToolTip(txt, "");

but it doesn't work fine. I need that the message be shown just when the
user press the bar space and not when the mouse pointer is over the
textbox.

The ToolTip.Show() method may accomplish what you want. But note that
simply showing the tooltip then sets it up for also showing when you
hover over the control. You'll have to remove the tooltip from the
control after it's been shown (i.e. call SetToolTip() once the tooltip
is no longer needed for the control). You can use the AutoPopDelay
property to find out how long the tooltip will be shown, so you can
anticipate when it no longer is needed.

Pete
 

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

Top