c#单击窗体按钮消失代码怎么写?

来源:百度知道 编辑:UC知道 时间:2024/09/24 04:23:43
我用的是VisualC#2005,请问我要实现单击窗体时按钮消失双击窗体时按钮重新显示,并且按钮一直跟着鼠标走,我要怎么来写代码啊?急需,谢谢!

public partial class Form1 : Form
{
int offset = 5;
public Form1()
{
InitializeComponent();
}

private void Form1_Click(object sender, EventArgs e)
{
button1.Visible = false;
}

private void Form1_DoubleClick(object sender, EventArgs e)
{
button1.Visible = true;
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (button1.Visible)
button1.Location = new Point(e.X + offset, e.Y + offset);
}

}