【发布时间】:2017-11-05 04:18:20
【问题描述】:
【问题讨论】:
-
您不必使用多个事件。您可以在单个事件本身中完成它
标签: c# winforms visual-studio-2015
【问题讨论】:
标签: c# winforms visual-studio-2015
以下是前进按钮的示例代码,您可以自己后退。希望这可以帮到你。
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
enum stringLocation : int
{
label1,label2, label3, label4
}
int location =(int) stringLocation.label1;
string contentToMove= "0";
public Form1()
{
InitializeComponent();
}
private void forward_Click(object sender, EventArgs e)
{
location = (location+1) % 4;
switch (location){
case (int) stringLocation.label1:
label1.Text = contentToMove;
label2.Text = "";
label3.Text = "";
label4.Text = "";
break;
case (int) stringLocation.label2:
label1.Text = "";
label2.Text = contentToMove;
label3.Text = "";
label4.Text = "";
break;
case (int) stringLocation.label3:
label1.Text = "";
label2.Text = "";
label3.Text = contentToMove;
label4.Text = "";
break;
case (int)stringLocation.label4:
label1.Text = "";
label2.Text = "";
label3.Text = "";
label4.Text = contentToMove;
break;
default:
break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = contentToMove;
label2.Text = "";
label3.Text = "";
label4.Text = "";
}
}
}
【讨论】: