How to refresh/reload form

I have two child forms -- Form1 and Form2.

Form1 calls Form2. When Form2 closes, it will return to Form1. How can I refresh or reload Form1

Thanks a lot!! :D


Answer this question

How to refresh/reload form

  • Rick1138

    It's like this: When Form2 returns to Form1, Form1 must know that Form2 has closed.. 

    But thanks for the reply, anyway. :)

  • ZBizKiT

    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.
  • Peter Kryszak

    Hi!! My code's already working.

    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

    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;
      }
    }

  • KrisRicher

    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