我点击按钮时尝试更改标签,但由于某种原因它无法正常工作。它一直在工作,直到我做了一点改变,我不知道该怎么做了。有人可以帮忙吗?这是代码:
private void btnColorChange_Click(object sender, EventArgs e)
{
if (lblTvalue.Text = "1")
{
lblTest.Text = "$0.00";
}
if (lblTvalue.Text = "2")
{
lblTest.Text = "$2.00";
}
}
答案 0 :(得分:2)
确保在IF(x.x == x)中放置2 " equals" ,如:
private void btnColorChange_Click(object sender, EventArgs e)
{
if (lblTvalue.Text == "1")
{
lblTest.Text = "$0.00";
}
if (lblTvalue.Text == "2")
{
lblTest.Text = "$2.00";
}
}