首页 新闻 会员 周边

Winform 气泡提示

0
悬赏园豆:5 [已关闭问题] 关闭于 2012-08-15 11:37

我现在需要当鼠标移到textbox控件上然后显示气泡提示,当鼠标离开textbox 控件的时候取消气泡提示,我已经用了tooltip控件但是只能显示一会,我希望当鼠标离开textbox控件时,取消气泡显示,我该怎么做呢,请帮帮忙,在线等,感激不尽!!!

刘颖的主页 刘颖 | 初学一级 | 园豆:6
提问于:2012-02-23 13:22
< >
分享
所有回答(3)
1

考虑使用一个无边框的小窗体替代tooltip,编辑textbox的mouse_enter和mouse_leave事件,分别show和close这个小窗体,可以模拟tooltip效果,同时又可以有更多的控制。

致远书生 | 园豆:409 (菜鸟二级) | 2012-02-23 13:41

这到是个好办法,但是怎么制作tooltip弹出框的效果窗体呢?

支持(0) 反对(0) 刘颖 | 园豆:6 (初学一级) | 2012-02-23 13:43

@刘颖: 放一个时间控件进行定时,Show和Close的时候可以实现渐显和渐隐的效果。我不知道你说的是不是这个效果?

支持(0) 反对(0) 致远书生 | 园豆:409 (菜鸟二级) | 2012-02-23 13:45
0

编辑textbox的mouse_enter和mouse_leave事件

悟行 | 园豆:12559 (专家六级) | 2012-02-23 14:15

Form f=new Form();

 Point p= new Point(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y + 23);
            f.Show();

为什么位置读取的不对啊,这是为什么啊,我已经设计了,

x 为500 Y 600 可是现实就变成 X 20 Y 30

支持(0) 反对(0) 刘颖 | 园豆:6 (初学一级) | 2012-02-23 14:55

@刘颖: 你可以在鼠标事件中写,用e.x和e.y就可以了。

支持(0) 反对(0) 悟行 | 园豆:12559 (专家六级) | 2012-02-23 15:35
0

用自带的ToolTip: 看这里http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.aspx

顺便复制一段代码过来:

      private void Form1_Load(object sender, System.EventArgs e)
{
// Create the ToolTip and associate with the Form container.
ToolTip toolTip1 = new ToolTip();

// Set up the delays for the ToolTip.
toolTip1.AutoPopDelay = 5000;
toolTip1.InitialDelay = 1000;
toolTip1.ReshowDelay = 500;
// Force the ToolTip text to be displayed whether or not the form is active.
toolTip1.ShowAlways = true;

// Set up the ToolTip text for the Button and Checkbox.
toolTip1.SetToolTip(this.button1, "My button1");
toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
}

另外CodeProject上面有个弄了个差不多的效果:http://www.codeproject.com/Articles/4991/Balloon-Tips-Galore

_A_A | 园豆:1139 (小虾三级) | 2012-02-23 17:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册