您的位置:首页 > 编程语言 > C#

C#的tooltip自动消失之后就不再显示了解决办法

2013-07-04 22:17 585 查看
转:http://www.51testing.com/?uid-569418-action-viewspace-itemid-832231
在控件上加上tooltip之后,鼠标放到控件上,tooltip出来,等tooltip自动消失之后,再将鼠标放到控件上去时就不会再显示tooltip了

解决方法:给tooltip加上MouseEnter 和MouseLeave的事件,在事件里面设置tooltip的Active状态

Label label= new Label();
ToolTip toolTip1 = new ToolTip();
toolTip1.AutoPopDelay = 5000;
toolTip1.InitialDelay = 500;
toolTip1.ReshowDelay = 500;
toolTip1.ShowAlways = true;
toolTip1.SetToolTip(this.label, "提示的内容");
toolTip1.ToolTipTitle = "提示的标题";
label.MouseEnter += new System.EventHandler(this.toolTip1_MouseEnter);
label.MouseLeave += new System.EventHandler(this.toolTip1_MouseLeave);

private void toolTip1_MouseEnter(object sender, EventArgs e)
{
this.toolTip1.Active = true;
}

private void toolTip1_MouseLeave(object sender, EventArgs e)
{
this.toolTip1.Active = false;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: