How to make Form1 label.text change when checkbox on form2 is checked?

In this scenario you could use the CheckedChanged event:

public void checkbox2_CheckedChanged(object sender, EventArgs e) {
    if (checkbox2.Checked) 
    {
        Form1.Label1.Text = "Checkbox 2 has been checked";
    } else 
     { 
        Form1.Label1.Text = "";
     }
}

http://www.c-sharpcorner.com/uploadfile/mahesh/checkbox-in-C-Sharp3/

Note you will have to change the Access Modifier in Form1 and make Label1 public so Form2 can alter the Text property.

To do this, goto Form1, select Label1 goto Properties, select Modifiers and change from Private to Public. Form2 will then have access to the Label.

Leave a Comment