110,534
社区成员
发帖
与我相关
我的任务
分享
public Form1()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
Point btnOneP = btnOne.Location;
Point btnTwoP = btnTwo.Location;
int btnNum = 0;
btnOne.MouseEnter += delegate
{
btnOne.Text = "是的";
btnTwo.Text = "不是";
btnNum++;
if (btnNum == 4)
{
btnOne.Location = new Point(btnOne.Location.X, btnOne.Location.Y - 30);
btnOne.Text = "不是";
btnTwo.Text = "是的";
}
if (btnNum == 6)
{
btnOne.Location = btnOneP;
btnNum = 0;
}
};
btnTwo.MouseEnter += delegate
{
btnTwo.Text = "是的";
btnOne.Text = "不是";
btnNum++;
if (btnNum == 4 )
{
btnTwo.Location = new Point(btnTwo.Location.X, btnTwo.Location.Y - 30);
btnTwo.Text = "不是";
btnOne.Text = "是的";
}
if (btnNum == 6)
{
btnTwo.Location = btnTwoP;
btnNum = 0;
}
};
this.FormClosing += (sender, e) =>
{
MessageBox.Show("你就是喜欢我!");
e.Cancel = true;
};
}
private void button1_MouseEnter(object sender, EventArgs e)
{
button1.Text = "是";
button2.Text = "不是";
button1.Top = 203;
}
private void button2_MouseEnter(object sender, EventArgs e)
{
button1.Text = "不是";
button2.Text = "是";
button2.Top =203;
}
private void button1_Click(object sender, EventArgs e)
{
button2.Top = 100;
}
private void button2_Click(object sender, EventArgs e)
{
button1.Top = 100;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
MessageBox.Show("你就是喜欢我");
e.Cancel = true;
}
效果应该差不多,事件自己对应写就好了