Refreshing Parent window from child window

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    Refreshing Parent window from child window

    I have a Form parent window with a list view on it.
    When I click on an item I open another form to edit the details - this
    is not and cannot be a dialog window.

    When I close the child window I would like the parent window to
    automatically refresh by calling a method RefreshData().

    How can I achieve this.

    Regards
    Jeff
  • Alberto Poblacion

    #2
    Re: Refreshing Parent window from child window

    "Jeff" <jeff@[_nospam_].hardsoft.com.a uwrote in message
    news:00ba87c3$0 $20320$c3e8da3@ news.astraweb.c om...
    >I have a Form parent window with a list view on it.
    When I click on an item I open another form to edit the details - this is
    not and cannot be a dialog window.
    >
    When I close the child window I would like the parent window to
    automatically refresh by calling a method RefreshData().
    >
    How can I achieve this.
    In the parent form you are probably opening the child form in a way
    similar to this:

    MyEditForm frm = new MyEditForm();
    frm.Show();

    In between those lines, you can add an event handler to the form:

    frm.Closed += new EventHandler(Re freshData);

    This connects your "RefreshDat a" routine to the Closed event of the
    form, so when the form is closed your method will be called as you wanted.
    Note that for this to compile, the RefreshData method needs to have the
    proper signature for an EventHandler, i.e. void RefreshData(obj ect sender,
    EventArgs e).

    Comment

    • Jeff

      #3
      Re: Refreshing Parent window from child window

      Thanks Alberto

      Its exactly what I needed


      Alberto Poblacion wrote:
      "Jeff" <jeff@[_nospam_].hardsoft.com.a uwrote in message
      news:00ba87c3$0 $20320$c3e8da3@ news.astraweb.c om...
      >I have a Form parent window with a list view on it.
      >When I click on an item I open another form to edit the details - this
      >is not and cannot be a dialog window.
      >>
      >When I close the child window I would like the parent window to
      >automaticall y refresh by calling a method RefreshData().
      >>
      >How can I achieve this.
      >
      In the parent form you are probably opening the child form in a way
      similar to this:
      >
      MyEditForm frm = new MyEditForm();
      frm.Show();
      >
      In between those lines, you can add an event handler to the form:
      >
      frm.Closed += new EventHandler(Re freshData);
      >
      This connects your "RefreshDat a" routine to the Closed event of the
      form, so when the form is closed your method will be called as you wanted.
      Note that for this to compile, the RefreshData method needs to have
      the proper signature for an EventHandler, i.e. void RefreshData(obj ect
      sender, EventArgs e).
      >

      Comment

      Working...