I am trying to add tool tip to a dithered textbox in winform. For adding the tooltip, mouse hover event is needed but in case of dithered text box, mouse hover event doesn't fire. Is there any other way to add tooltip for mouse hovering?
When the user hovers over this dithered textbox, the entire content of textbox should display in tooltip.
ToolTip doesn't show for TextBox the first time that mouse hovers on it.
It seems the tooltip for TextBox
only appears on second hover event. It doesn't matter whether the TextBox
is ReadOnly
or not. But as a workaround, you can handle MouseHover
and MouseLeave
events yourself and write such code:
private void textBox1_MouseHover(object sender, EventArgs e)
{
var point = this.textBox1.PointToClient(Cursor.Position);
point.Offset(0, 20);
this.toolTip1.Show("Some Text", this.textBox1,
point, 2000);
}
private void textBox1_MouseLeave(object sender, EventArgs e)
{
this.toolTip1.Hide(this.textBox1);
}
Here is the screenshot of behavior before fix:
Screenshot after fix: