简体   繁体   中英

How do I change the name of a label if a specific radio button is checked?

Through coding, if lets say radioButton2 is checked, how do I have the Text property for the Label label1 change to, for example, "Enter a different value"?

private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {

    }

This is very simple you should keep exploring but just for help

private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
           if(radioButton2.Checked)
           {

              label1.Text = "Enter a different value";
           }
        }

Well, why can't you just set the Text property of label in your event handler like

private void radioButton2_CheckedChanged(object sender, EventArgs e)
    {
       label1.Text = "Enter a different value";
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM