ToolStrip buttons are blinking

I have a window form with a tooltip in it with multiple buttons. When the mouse is over a toolbar button then the toolbar button starts blinking ... it looks like it gains and loses focus every second. This results in the click doing nothing if the user clicks while the button has no focus, so the user needs to click the button again and use it correctly.

Does anyone know about this?

I need to get answers as soon as possible ...

Many thanks

+2


source to share


2 answers


I found the reason ... Toolbars in window forms have tooltips set to Auto by default and if the tooltip opens on the taskbar then the toolbar loses focus.



The solution to this is to either turn off the tooltips, or set it to manual and show the tooltip elsewhere.

+4


source


Here is the code to manually show the tool tip over an element:

private readonly ToolTip currentToolTip = new ToolTip();

private void ToolStripItem_MouseEnter(object sender, EventArgs e)
{
    ToolStripItem item = (ToolStripItem)sender;
    this.currentToolTip.Show(item.ToolTipText, item.Owner, item.Bounds.X, -20);
}

private void ToolStripItem_MouseLeave(object sender, EventArgs e)
{
    ToolStripItem item = (ToolStripItem)sender;
    this.currentToolTip.Hide(item.Owner);
}

      



You need to add event handlers to all ToolStripItems and set ShowItemToolTips ToolStrips to false.

+1


source







All Articles