WinForms 工具提示未显示 [英] WinForms tooltips not showing up

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

问题描述

我有一个 WinForms 应用程序.每个表单和用户控件设置其工具提示如下:

I have a WinForms application. Each form and user control sets up its tooltips as follows:

// in the control constructor
var toolTip = new ToolTip();
this.Disposed += (o, e) => toolTip.Dispose();
toolTip.SetToolTip(this.someButton, "...");
toolTip.SetToolTip(this.someCheckBox, "...");
...

但是,当我将鼠标悬停在控件上时,工具提示不会出现.这是使用工具提示的适当方式吗?应用程序的另一部分(例如,监听某些事件)中是否发生了会阻止工具提示工作的事情?

However, the tooltips don't appear when I hover over the controls. Is this an appropriate way to use tooltips? Is there something that could be happening in another part of the application (e. g. listening to some event) that would stop tooltips from working?

请注意,我的外部表单的工具条按钮(通过按钮的工具提示属性配置)上的工具提示确实可以按预期工作.

Note that tooltips on my outer form's toolstrip buttons (which are configured via the button's tooltip property) do work as expected.

我对此进行了更多观察,并且注意到有时确实会显示工具提示,它只是非常不稳定".基本上,有时当我将鼠标悬停在控件上时,它会非常短暂地显示出来,然后闪烁消失.我可以使用 .Show() 和较长的 AutoPopDelay 手动显示它,但它永远不会消失!

I've observed this more and I've noticed that sometimes the tooltip does show up, it is just extremely "flaky". Basically, sometimes when I mouse over a control it will show up very briefly and then flicker away. I can get it to show manually with .Show() and a long AutoPopDelay, but then it never disappears!

推荐答案

当我的工具提示没有在 RichTextBox 上出现一次时,我遇到了类似的问题,大约 3-5 次,它通常应该出现.即使使用 toolTip.Show 强制它显式显示也无济于事.直到我更改为 Shell 提到的方式 - 您必须告诉 您希望工具提示出现在哪里:

I faced similar issue when my tooltip was not showing up over the RichTextBox once in about 3-5 times it normally should. Even forcing it to show explicitly with toolTip.Show didn't help. Until I changed to the way mentioned by Shell - you have to tell where you want your tooltip to appear:

'Dim pnt As Point
pnt = control.PointToClient(Cursor.Position)
pnt.X += 10 ' Give a little offset
pnt.Y += 10 ' so tooltip will look neat
toolTip.Show(text, control, pnt)

这样,我的工具提示总是会出现在何时在哪里预期.祝你好运!

This way my tooltip always appears when and where expected. Good luck!

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

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