我必须用(c#)创建一个windows窗体,
- 3 个轨迹栏
- 1 个按钮
- 1 个标签
使用 if 和 else if 命令。我的问题是,我无法让最终结果显示在 label1 中。我确实设法在labels2-4中显示它们。但这不是完成这项任务的方法。
这是代码。
{
public Form1()
{
InitializeComponent();
trackBar1.Maximum = 10;
trackBar1.Minimum = 0;
trackBar2.Maximum = 10;
trackBar2.Minimum = 0;
trackBar3.Maximum = 10;
trackBar3.Minimum = 0;
}
private void button1_Click(object sender, EventArgs e)
{
int a;
int b;
int c;
a = Convert.ToInt32 (trackBar1.Value);
b = Convert.ToInt32 (trackBar2.Value);
c = Convert.ToInt32 (trackBar3.Value);
int d;
int E;
int f;
if ((a < b) && (a < c)&& (b> c))
{
label2.Text = Convert.ToString(d = a);
label3.Text = Convert.ToString(E = c);
label4.Text = Convert.ToString(f = b);
label1.Text =Convert.ToString (string d,e,f);
}
if ((a < b) && (a < c) && (b < c))
{
label2.Text = Convert.ToString(d = a);
label3.Text = Convert.ToString(E = b);
label4.Text = Convert.ToString(f = c);
}
else if ((a > c) && (a > b) && (b > c))
{
label2.Text = Convert.ToString(d = c);
label3.Text = Convert.ToString(E = b);
label4.Text = Convert.ToString(f = a);
}
else if ((a < c) && (a > b) && (b > c))
{
label2.Text = Convert.ToString(d = c);
label3.Text = Convert.ToString(E = a);
label4.Text = Convert.ToString(f = b);
}
else if ((b < a) && (b < c) && (c > a))
{
label2.Text = Convert.ToString(d = b);
label3.Text = Convert.ToString(E = a);
label4.Text = Convert.ToString(f = c);
}
else if ((b < a) && (b < c) && (c < a))
{
label2.Text = Convert.ToString(d = b);
label3.Text = Convert.ToString(E = c);
label4.Text = Convert.ToString(f = a);
}
}
我需要 label1.Text 作为标签 2-4 的结果,我尝试了这个 label1.Text= Convert.ToString(d = b + E = c + f = a) 并且我尝试将 + 替换为 ,但这不起作用任何一个。我想我必须使用字符串格式,但我不知道如何以及是否需要。