Tab控件的动态工具提示 [英] Dynamic tool tips for Tab control

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

问题描述

大家好



我有一个ShowToolTips = true的标签控件。

它适用于我指定的静态工具提示使用ToolTipText属性的选项卡。

现在我需要使工具提示动态,即在显示之前更改提示的文本,具体取决于选项卡内容。所以,我想使用MouseHover事件来检查我所在的选项卡并更改相应的ToolTipText。不幸的是,TabControl.MouseHover事件并没有告诉我鼠标悬停在哪个标签上。



我还可以使用其他活动/物业吗?



谢谢

Hi all

I have a tab control with ShowToolTips = true.
It works fine for static tool tips that I assigned to the tabs using ToolTipText property.
Now I need to make the tool tips dynamic, i.e. change the tip's text before showing it, depending on the tab contents. So, I'd like to use something like MouseHover event to check which tab I am in and change the corresponding ToolTipText. Unfortunately, TabControl.MouseHover event does not tell me which tab the mouse hovers on.

Is there any other event/property I can use?

Thank you

推荐答案

TabControl支持selectedIndexChaged事件。你可以试试这个:



TabControl supports selectedIndexChaged event. You can try this:

private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
    if (tabControl1.SelectedTab == tabPage1)
        toolTip1.SetToolTip(tabControl1, "TabPage1");
    else if (tabControl1.SelectedTab == tabPage1)
        toolTip1.SetToolTip(tabControl1, "TabPage2");
}







但也许您应该考虑为每个标签页分配工具提示值。这样您就不需要进行任何编码了。




But perhaps you shoud consider to assign tooltip value for each individual tab page. This way you don't need to do any coding.


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

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