It is not possible to change the properties in the parent form at all. Instead, your child form should raise the event that the parent form is listening on and change its own value accordingly.
Manipulating the parent form from the child creates a two-way relationship - the parent form owns the child, but the child also has close knowledge and dependence on the parent form. Bubbling is an established solution for this, as it allows information to flow upward (a βbubbleβ), while avoiding any strict connection.
Here is the simplest example of eventing. It does not include the transmission of certain information in the event (which you may need), but it covers the concept.
In your child form:
//the event public event EventHandler SomethingHappened; protected virtual void OnSomethingHappened(EventArgs e) { //make sure we have someone subscribed to our event before we try to raise it if(this.SomethingHappened != null) { this.SomethingHappened(this, e); } } private void SomeMethod() { //call our method when we want to raise the event OnSomethingHappened(EventArgs.Empty); }
And in your parent form:
void OnInit(EventArgs e) {
As I said above, you probably need to pass certain information to your event. There are several ways to do this, but the easiest is to create your own EventArgs class and your own delegate. It looks like you need to indicate if any value is set to true or false, so use this:
public class BooleanValueChangedEventArgs : EventArgs { public bool NewValue; public BooleanValueChangedEventArgs(bool value) : base() { this.NewValue = value; } } public delegate void HandleBooleanValueChange(object sender, BooleanValueChangedEventArgs e);
We can change our event to use these new signatures:
public event HandleBooleanValueChange SomethingHappened;
And we pass our custom EventArgs object:
bool checked =
And we accordingly change the event handling in the parent device:
void OnInit(EventArgs e) {