我想扩大弗明的答案,以便可能使他的美妙的解决方案稍微更清晰。
在您工作的表单中(很可能在.Designer.cs文件中),您需要向您的CheckedListBox添加一个MouseMove事件处理程序(Fermin最初建议使用MouseHover事件处理程序,但这不适用于我)。
this.checkedListBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.showCheckBoxToolTip);
接着,添加两个类属性到表单,工具提示对象和整数跟踪过去的复选框,其刀尖被证明
private ToolTip toolTip1;
private int toolTipIndex;
最后,你需要实现showCheckBoxToolTip () 方法。除了我将事件回调方法与ShowToolTip()方法相结合之外,此方法与Fermin的答案非常相似。另请注意,其中一个方法参数是MouseEventArgs。这是因为MouseMove属性需要一个MouseEventHandler,然后提供MouseEventArgs。
private void showCheckBoxToolTip(object sender, MouseEventArgs e)
{
if (toolTipIndex != this.checkedListBox.IndexFromPoint(e.Location))
{
toolTipIndex = checkedListBox.IndexFromPoint(checkedListBox.PointToClient(MousePosition));
if (toolTipIndex > -1)
{
toolTip1.SetToolTip(checkedListBox, checkedListBox.Items[toolTipIndex].ToString());
}
}
}
的`点p`线不是必需的 – Maslow 2014-09-25 17:23:06