There are several different solutions to update the parent form's control, from the child non-top-level form. For example, you can use either of the following options:
- In the child form, you can find the label1 like this:
var label = (Label)this.FindForm().Controls.Find("label1", true)[0];
- You can make the
label1
Modifiers property topublic
and GenerateMember totrue
. Then find the label like this:var label = ((Form1)this.FindForm()).label1;
- Just define a
Label
property for the child form, and after you instantiated the child form, set itsLabel
property tothis.lable1
. - Whenever you want to set the value of
label1
, you can raise an event, and pass the value to the event arguments, then in the event handler in the main form, set the value of label1. - Define a property of type of
Action<string>
for your child form, and then after you instantiate the child form, set it to(x)=> label1.Text = x;
, later whenever you want to set the value, just call the action and pass the value to it.
Wanna see more example? Take a look at the following posts: