简体   繁体   中英

How to control parent form from modally called child form

Is it possible to control the parent form from a modal child form?

My only idea is to close the parent form and show child form via ChildForm.Show() and not ChildForm.ShowDialog(parentform) , can I control parent form from modally displayed child form?

How to refresh a parent form automatically upon saving the update on the child form?

You can access the parent (Owner) form by using Owner property. If you show the dialog using:

childForm.ShowDialog(this);

( this will be the form from where you are showing the dialog)

then in the dialog:

this.Owner.BackColor=System.Drawing.Color.Coral;

This will change the background colour of the parent form immediately.

ParentForm is available in the context of MDIForm context.

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