码迷,mamicode.com
首页 > 其他好文 > 详细

02 button的练习

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

标签:text   ons   cancel   new   question   bsp   ble   ext   for   

 

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的练习

标签:text   ons   cancel   new   question   bsp   ble   ext   for   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!