我现在有一个panel上面是用来显示视频图像的。。但是我希望把控制图像的按钮也放在panel上,当鼠标移到pannel上时按钮就出现而且可以操作怎么实现,我的程序是winform的。(现在用我的方法是当我把鼠标移到按钮上时就不在panel上按钮就隐藏了。)求求各位大神们伸出你们的援手帮帮俺。新学在此跪谢了!
解决方案 »
- 请问这个button怎样添加
- C# 向数据库添加数数据,检验数据库中是否存在相同的数据
- 怎么在.net 页面中用javascript输出对话框后,再进行Response.Redirect转向??
- 初学者提问: 'aa,bb' 转化成 'aa','bb' 的代码
- 如何通过C#修改计算机系统时间?急急!
- 如何用c#怎么获得系统的分辩率
- 如何将txt(多列)导入到gridview或者listview中
- 用C#控制EXCEL时,怎样控制一个单元格内当字符窜由于过长的时候让它自动换行?
- 这样为何不行?
- C#中如何将类库文件中的数组数据赋值给界面上的label控件并显示
- 一个郁闷的问题,求教
- C#怎么返回原来的地方
MouseEnter事件 与 MouseLeave这两个事件
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication4
{
public partial class Form4 : Form
{
public Form4()
{
InitializeComponent();
}
//按钮在一个Panel里面 private void panel1_MouseMove(object sender, MouseEventArgs e)
{
this.button1.Visible = true;
} private void panel1_MouseLeave(object sender, EventArgs e)
{
this.button1.Visible = false;
}
}
}
bool IsVisible = false;private void panel1_MouseLeave(object sender, EventArgs e)
{
new System.Threading.Thread(_ => {
System.Threading.Thread.Sleep(100);
if (!IsVisible)
{
this.Invoke(new Action(() => button3.Visible = false));
IsVisible = false;
}
}).Start();
} private void button3_MouseEnter(object sender, EventArgs e)
{
IsVisible = true;
} private void panel1_MouseEnter(object sender, EventArgs e)
{
button3.Visible = true;
} private void button3_MouseLeave(object sender, EventArgs e)
{
IsVisible = false;
}
{
this.button1.Visible = true;
} private void panel1_MouseLeave(object sender, EventArgs e)
{
Rectangle rect = new Rectangle(this.panel1.Location, this.panel1.Size);
if(rect.Contains(this.PointToClient(Control.MousePosition)))
this.button1.Visible = true;
else
this.button1.Visible = false;
}
的方法还有点小缺陷,谢谢大家的帮助了
private bool IsMouseOver()
{
return Control.MousePosition.X > this.Location.X + panel1.Location.X + 8
&& Control.MousePosition.X < this.Location.X + panel1.Location.X + panel1.Size.Width
&& Control.MousePosition.Y > this.Location.Y + panel1.Location.Y + 30
&& Control.MousePosition.Y < this.Location.Y + panel1.Location.Y + panel1.Size.Height;
}
private void panel1_MouseLeave(object sender, EventArgs e)
{
if (!IsMouseOver())
this.button6.Visible = false;
else
this.button6.Visible = true;
}private void panel1_MouseEnter(object sender, EventArgs e)
{
this.button6.Visible = true;
}