02 button的练习
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了02 button的练习相关的知识,希望对你有一定的参考价值。
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的练习的主要内容,如果未能解决你的问题,请参考以下文章
攻防世界WEB练习区(backupcookiedisabled_button)
IOS开发-UI学习-根据URL显示图片,下载图片的练习(button,textfield,image view,url,data)