When form2.ShowDialog() closes control is given back to form1. Otherwise you must look into Thread Methods. Modeless dialogs are controlled by there parents and ught to be set to null when they close to allow tests.
I used MDI before, so I found it difficult to refresh the forms because they were both considered child forms. This time, I used the normal parent-child forms so it already worked.
one way you can do this is in the close event handler
foreach ( System.Windows.Forms.Form form in this.MDIParent.MDIChildren) { if (form.GetType() == typeof(Form1) { form.Refresh(); // or if you need for it to reload all values completely.. have a method in form 1 // that will reload all the controls as you need it to be. form.Activate(); break; } }
Curious question for you, is this question postulated before you tried it I have the situation where when Form2 closes (a dialog) Form1 (the main screen) disappears for a few seconds before returning to the screen, so it refreshes too much.
In your case a <strong>Form1.Invalidate()</strong> ought to be enough, without seeing your code I can't see why Form1 does not refresh, Windows ought to take care of that! As said I have the reverse problem, I haven't coded a Form1.Hide(); Form1.Show(); Most times Windows produces far to many messages, a refreshed screen need not be refresehed when nothing hapens. This curious behaviour can't be stopped. (at least I don't know how)
How to refresh/reload form
Rick1138
But thanks for the reply, anyway. :)
ZBizKiT
Peter Kryszak
I used MDI before, so I found it difficult to refresh the forms because they were both considered child forms. This time, I used the normal parent-child forms so it already worked.
Thanks. :D
JayMo
foreach ( System.Windows.Forms.Form form in this.MDIParent.MDIChildren) {
if (form.GetType() == typeof(Form1) {
form.Refresh();
// or if you need for it to reload all values completely.. have a method in form 1
// that will reload all the controls as you need it to be.
form.Activate();
break;
}
}
KrisRicher
In your case a <strong>Form1.Invalidate()</strong> ought to be enough, without seeing your code I can't see why Form1 does not refresh, Windows ought to take care of that! As said I have the reverse problem, I haven't coded a Form1.Hide(); Form1.Show(); Most times Windows produces far to many messages, a refreshed screen need not be refresehed when nothing hapens. This curious behaviour can't be stopped. (at least I don't know how)