我目前正在 C# 上创建一个计算器类型的表单。我有四个单选按钮(加法、减法、多重和 div)和两个文本框之间的标签。标签根据所选单选按钮更改,(例如,如果我选择了添加单选按钮,标签将显示为“+”)。我在使用此代码时遇到的问题:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked == true)
{
label3.Text = ("+");
}
else if (radioButton2.Checked == true)
{
label3.Text = ("-");
}
else if (radioButton3.Checked == true)
{
label3.Text = ("x");
}
else if (radioButton4.Checked == true)
{
label3.Text = ("/");
}
}
is when I select the division button the label does not change unless I go through all the buttons and THEN other radio buttons (such as subtraction), when selected, do not change the label until multiple tries. 我尝试将最后一行更改为 "else label3.text=("/");" 但除了错误的顺序之外,它并没有真正改变任何东西。任何帮助,将不胜感激!谢谢 :)