首页 > 其他 > 详细

02 button的练习

时间:2016-12-23 01:21:02      阅读:184      评论:0      收藏:0      [点我收藏+]

 

private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("我也喜欢你!");
//if (this.button1.Text == "喜欢")
//{
// button2.Visible = false;
//}

}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("我还不喜欢你呢!");
//if (this.button2.Text == "不喜欢")
//{
// button1.Visible = false;
//}


}

private void button2_MouseMove(object sender, MouseEventArgs e)
{
//Button2移动 不让鼠标点到
Random suiJi = new Random();
int x = suiJi.Next(0,this.Size.Width-this.button2.Size.Width);
int y = suiJi.Next(0,this.ClientSize.Height-this.button2.Size.Height);

Point p = new Point(x,y);
button2.Location = p;

}

private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("做个测试吧!!"); //messagebox是一个类型 类型后面要跟.

}

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
//窗体关闭事件的简单写法
DialogResult re = MessageBox.Show("确定关闭吗", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (re == DialogResult.No)
{
e.Cancel = true;
}
}

02 button的练习

原文:http://www.cnblogs.com/xcyg/p/6213289.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!