工具提示的CheckedListBox项目? [英] Tooltips for CheckedListBox items?

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

问题描述

有没有设置,当用户的鼠标在的CheckedListBox保持在某个项目出现在提示的附加文本的简单明了的方式?

Is there a straighforward way to set additional text to appear in a tooltip when a user's mouse is held over an item in a CheckedListBox?

我会的期望的能在代码做的是:

What I would expect to be able to do in code is:

uiChkLstTables.DisplayOnHoverMember = "DisplayOnHoverProperty"; //Property contains extended details



任何人都可以点我在正确的方向做到这一点?我已经发现一对夫妇的涉及检测哪个项目鼠标目前超过并创建一个新的工具提示实例的文章,但是这听起来有点太做作是最好的办法。

Can anyone point me in the right direction to do this? I've already found a couple of articles that involve detecting which item the mouse is currently over and creating a new tooltip instance, but this sounds a little too contrived to be the best way.

先谢谢了。

推荐答案

工具提示对象添加到您的窗体,然后添加了的CheckedListBox事件处理程序。 MouseHover调用的方法ShowToolTip();
添加您的CheckedListBox它具有以下代码的MouseMove事件:

Add a Tooltip object to your form and then add an event handler for the CheckedListBox.MouseHover that calls a method ShowToolTip(); Add MouseMove event of your CheckedListBox which has the following code:

//Make ttIndex a global integer variable to store index of item currently showing tooltip.
//Check if current location is different from item having tooltip, if so call method
if (ttIndex != checkedListBox1.IndexFromPoint(e.Location))
                ShowToolTip();



然后创建ShowToolTip方式:

Then create the ShowToolTip method:

private void ShowToolTip()
    {
        ttIndex = checkedListBox1.IndexFromPoint(checkedListBox1.PointToClient(MousePosition));
        if (ttIndex > -1)
        {
            Point p = PointToClient(MousePosition);
            toolTip1.ToolTipTitle = "Tooltip Title";
            toolTip1.SetToolTip(checkedListBox1, checkedListBox1.Items[ttIndex].ToString());

        }
    }

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

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