简体   繁体   English

自定义控件的工具提示

[英]Tooltip on custom control

I created a custom control (inherited from UserControl) with some controls in it (label, textbox, slider) and assigned it a supertooltip (from devComponents dotnetbar; same problem with normal; check picture) in Designer. 我创建了一个自定义控件(继承自UserControl),其中包含一些控件(标签,文本框,滑块),并在Designer中为其指定了一个supertooltip(来自devComponents dotnetbar;与普通相同的问题;检查图片)。

But the tooltip doesn't come up. 但工具提示没有出现。 On "normal" controls it works, so it's a problem with the custom control. 在“普通”控件上它可以工作,所以这是自定义控件的问题。

Any idea what's wrong? 知道什么是错的吗?

Edit: Here's a sample: Download 编辑:这是一个示例: 下载

While making the sample i think I found the failure. 在制作样品时,我认为我发现了失败。 The tooltip comes only up if the mouse hovers the parent. 如果鼠标悬停在父级上,则工具提示才会出现。 Possible? 可能? If yes: Any idea how to fix? 如果是:任何想法如何解决?

替代文字

Setting the tooltip on the user control displays the tooltip only when you hover over 'empty' canvas of the user control, not when you hover over child controls that are part of the user control. 在用户控件上设置工具提示在将鼠标悬停在用户控件的“空”画布上时显示工具提示,而不是将鼠标悬停在属于用户控件的子控件上时。 This is by design, you need to manually implement some workaround if you want other behavior. 这是设计使然,如果您想要其他行为,则需要手动实施一些变通方法。

One suggestion that is mentioned (originally from www.msnewsgroups.net, but which is no longer available): 提到的一个建议(最初来自www.msnewsgroups.net,但不再可用):

The easy way to handle this problem is to have your UserControl export a ToolTop property that, when it's set, just sets the ToolTip properties of all of its component controls. 处理此问题的简单方法是让UserControl导出一个ToolTop属性,该属性在设置时只设置其所有组件控件的ToolTip属性。 The get accessor can just return the ToolTip from any component within the UserControl, as they'll all be the same. get访问器可以从UserControl中的任何组件返回ToolTip,因为它们都是相同的。

The only downside to doing it this way is that the tool tip will be redisplayed whenever the user moves from one component to another within the user control, so the tool tip can become annoyingly persistent at times. 这样做的唯一缺点是,只要用户在用户控件中从一个组件移动到另一个组件,工具提示就会被重新显示,因此工具提示有时会变得烦人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM