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

查看:53
本文介绍了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?

请注意,我的外部窗体的工具栏按钮上的工具提示(通过按钮的tooltip属性配置)可以正常工作.

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天全站免登陆