CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2010
    Posts
    4

    Refresh Parent window after closing child window

    Hi,

    I have a datagridview in the parent window and by clicking on it, a new window pop ups. After closing the child window, I want to refresh the parent window in order to show the changes. I tried to use the 'activate' event and it is not working. Could any one please help me out!

  2. #2
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: Refresh Parent window after closing child window

    Are you showing the child window using ShowDialog? If so, after the ShowDialog, run your code that updates your DataGridView. Hopefully you have that code in it's own method so you simply add one line of code here.
    ===============================
    My Blog

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Refresh Parent window after closing child window

    Either what eclipsed said, or handle the child form's Close event.

  4. #4
    Join Date
    Jul 2010
    Posts
    82

    Re: Refresh Parent window after closing child window

    A datasource refresh should do once the child window closes. Most likely after the ShowDialog() call. Or you can also pass the parent window to child window and then update it from there. Else, use delegates and then update what you want in the callback function.

  5. #5
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Refresh Parent window after closing child window

    Quote Originally Posted by CuteAssistant View Post
    Or you can also pass the parent window to child window and then update it from there.
    Please don't do that. It is sloppy programming and there is no good reason to code this way.

  6. #6
    Join Date
    Jul 2010
    Posts
    4

    Re: Refresh Parent window after closing child window

    Thank you very much to all...It's working well!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured