显示在非重点的ToolStripItem工具提示 [英] Showing a tooltip on a non-focused ToolStripItem

查看:188
本文介绍了显示在非重点的ToolStripItem工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ToolStripItems显示激活的高亮当你把鼠标移到他们,即使他们是在形式不在焦点。他们不这样做,但是,显示其工具提示,除非形式的重点。我已经看到了 ToolStrip的点击 - 尽管黑客 。任何人都知道如何使ToolStripButton显示其提示时,它的父窗体没有焦点?

ToolStripItems show Active highlighting when you mouse over them, even if the form they are in is not in focus. They do not, however, show their tooltips, unless the form is focused. I have seen the ToolStrip 'click-though' hack. Anyone know how to make a ToolStripButton show its tooltip when its parent form is not in focus?

谢谢!

推荐答案

问题是,ToolStrip的控制之类的ToolStripButton或ToolStripDropDownButton不从Control继承。现在我通过集中每当用户将鼠标悬停在一个按钮ToolStrip的解决了这个问题。按钮的MouseHover事件被激发太晚了 - 显示工具提示code就会被运行后,所以我延长了ToolStripDropDownButton类,并用我的新按钮。这种方法应该适用于任何其他的类似按钮的类自ToolStripItem继承

The problem is that the ToolStrip "controls" like ToolStripButton or ToolStripDropDownButton don't inherit from Control. For now I addressed the problem by focusing the ToolStrip whenever a user hovers over a button. The button's MouseHover event is fired too late -- after the "show tooltip" code would have been run, so I extended the ToolStripDropDownButton class and used my new button. This method should work for any of the other button-like classes inheriting from ToolStripItem

public class ToolStripDropDownEx : ToolStripDropDownButton
{
    public ToolStripDropDownEx(string text)
    {
    }

    protected override void OnMouseHover(EventArgs e)
    {
        if (this.Parent != null)
            Parent.Focus();
        base.OnMouseHover(e);
    } 
}

这篇关于显示在非重点的ToolStripItem工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆