Label change when button click

75 Views Asked by At

I'm trying to make a label change when I click a button, but for some reason it is not working. It was working until I made a little change, and i do not know what to do anymore. Can some one help? Here is the code:

private void btnColorChange_Click(object sender, EventArgs e)
    {
        if (lblTvalue.Text = "1")
        {
            lblTest.Text = "$0.00";
        }
        if (lblTvalue.Text = "2")
        {
            lblTest.Text = "$2.00";
        }
    }
1

There are 1 best solutions below

0
On BEST ANSWER

Make sure you put 2 "equals" inside the IF(x.x == x) like:

private void btnColorChange_Click(object sender, EventArgs e)
{
    if (lblTvalue.Text == "1")
    {
        lblTest.Text = "$0.00";
    }
    if (lblTvalue.Text == "2")
    {
        lblTest.Text = "$2.00";
    }
}