c# - 自定义控件的工具提示

标签 c# winforms user-controls tooltip

我创建了一个自定义控件(继承自 UserControl),其中包含一些控件(标签、文本框、 slider ),并在 Designer 中为其分配了一个 supertooltip(来自 devComponents dotnetbar;与 normal 相同的问题;检查图片)。

但是工具提示没有出现。在“正常”控件上它可以工作,所以这是自定义控件的问题。

知道哪里出了问题吗?

编辑:这是一个示例:Download

在制作示例时,我认为我发现了失败。仅当鼠标悬停在父级上时才会出现工具提示。可能的?如果是:知道如何解决吗?

alt text

最佳答案

在用户控件上设置工具提示当您将鼠标悬停在用户控件的“空” Canvas 上时显示工具提示,而不是当您将鼠标悬停在作为用户控件一部分的子控件上时。这是设计使然,如果您想要其他行为,则需要手动实现一些解决方法。

提到的一个建议(最初来自 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. The get accessor can just return the ToolTip from any component within the UserControl, as they'll all be the same.

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.

关于c# - 自定义控件的工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4265918/

相关文章:

c# - 引用并存储动态创建的控件中的数据?

c# - 如何在 C# 中转义 XML 字符串中的无效字符

html - Windows 窗体中的 Web 浏览器控件不显示图像

java - 如何在 Java 或 C# 等静态类型语言中避免参数顺序依赖

c# - 这个 SQL 需要采用什么格式才能让 Oracle 接受它?

c# - Fire and Forgot 的异步/等待方法

wpf - 如何从 wpf 表单 View 模型访问用户控件中的组合框文本?

c# - Graphics.DrawString 斩波中间词

C# 多线程和套接字问题

c# - 什么是NullReferenceException,如何解决?