I am using a ToolTip
control on my form, but have discovered that even though my cursor is on one control, the tooltip is showing somewhere else. I would like to show this within the control my cursor is on.
As shown in the image above, when my cursor is over Textbox3
, the tooltip is showing on Textbox4
. I would like for it to be displayed pointing at Textbox3
.
I'm currently using the following code to display the tooltip in 3 different events:
private void txtImmediateddest_Enter(object sender, EventArgs e)
{
ttpDetail.Show("Ex:111000025", txtImmediateddest);
}
private void txtImmediateddest_MouseHover(object sender, EventArgs e)
{
ttpDetail.Show("Ex:111000025", txtImmediateddest);
}
private void txtImmediateddest_MouseUp(object sender, MouseEventArgs e)
{
ttpDetail.Show("Ex:111000025", txtImmediateddest, e.Location);
//toolTipimmeddest.Show("Required & Must be 9 Digits", txtImmediateddest);
}
Edit
private void textBox1_MouseHover(object sender, EventArgs e)
{
ttpDetail.AutoPopDelay = 2000;
ttpDetail.InitialDelay = 1000;
ttpDetail.ReshowDelay = 500;
ttpDetail.IsBalloon = true;
//ttpDetail.SetToolTip(textBox1, "Ex:01(Should be Numeric)");
ttpDetail.Show("Ex : 01(Should Be Numeric)", textBox1,textBox1.Width, textBox1.Height/10,5000);
}
This works fine but when the mouse initially on to the control it is displaying the normal if i had for second time it is displaying correctly
Look at the following images
The problem you're seeing is because your
ToolTip
control'sIsBalloon
property is set to "True". With this property set, theToolTip
doesn't change its relative location, causing the balloon's arrow to point to the wrong control.Here's a side-by-side comparison demonstrating this phenomenon:
The simple fix, obviously, is to disable the
IsBalloon
property by setting it to "False". The control will revert to displaying a standard, rectangular tooltip window, which will look correctly aligned.If that's not acceptable to you, then you will have to specify the exact location where you want the tooltip balloon to appear. Unfortunately, it looks like there's a bug in the
ToolTip
control that causes it not to appear properly the first time it is attached to a control. This can generally be fixed by calling theShow
method with an empty string once. For example, using the following code:produces this result:
Of course, your luck may vary going this route, as well. I generally don't use the built-in
ToolTip
control for edit controls (such as textboxes and comboboxes). I find it's much more reliable to P/InvokeSendMessage
, specifyingEM_SHOWBALLOONTIP
and anEDITBALLOONTIP
structure containing information about the tooltip that I want to show. I'll leave looking up the appropriate definitions and writing the wrapper code as an exercise for the reader, as this answer is much too long already.Have you tried to use only the SetToolTip method (with out calling the show method) in the MouseOver event
ttpTemp.SetToolTip(txtTemp, "Ex:01(Should be Numeric)");
This works fine for me (I use Managed C++ but I think it is the same).
Hey i got at last by this code
When MouseLeave
When Mouse Over
After a lot of troubleshooting I found the code bellow to be net superior to the build-in balloon ToolTip. Make sure Visual Styles are enabled by uncommenting the dependency in the manifest file.
Create a BalloonTip over a TextBox like this:
and implement
BalloonTip
like this:This is how it looks:
With credits to Chris' answer, I post VB.NET port here: