Results 1 to 6 of 6

Thread: [RESOLVED] Form Reload in Windows Application

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    134

    Resolved [RESOLVED] Form Reload in Windows Application

    Hi, I would like to cause my One of my Forms ( Parent Form ) to Reload when the Child Form closes. I know how this can be accomplised in Web Applications but not in Windows Applications. Can Anyone please tell me how?

    thanks in Advance

    Reaction
    Last edited by Reaction; May 22nd, 2007 at 06:32 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Form Reload in Windows Application

    There's no such thing as reloading a form in a Windows app. A form is "loaded" the first time it becomes visible and never again. You could destroy the form object and create a new one but there is no possible reason for that to be required.

    Presumably you mean you want the data displayed in the control(s) on a form to be updated with any changes you made in the child dialogue. If you've used data-binding properly then that will be taken care of automatically. See this thread for an example.

    Even if you haven't used data-binding, displaying data in a control is simply a matter of assigning the data to be displayed to the appropriate properties of the control displaying it. For instance, if you want to display unbound data in a TextBox you simply assign that data to its Text property. That's the case whether the form is being loaded or some dialogue has just been dismissed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    134

    Re: [2005] Form Reload in Windows Application

    What I want to do is Unload a Form and then load the forms Parent when the user clicks the Close Button on the form. Problem is I hid the parent form and instead would like to close it, open the child form and when the child form is closed, Open the parent form again as in reload it.


    Me.close() does not work


    vb Code:
    1. Private Sub Vendor_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    2.         If MessageBox.Show("Do you want to exit application completely?", "Quit Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
    3.             'do nothing
    4.             Application.Exit()
    5.         Else
    6.             'e.Cancel = True
    7.             Me.Close()
    8.         End If
    9.  
    10.     End Sub


    Can you suggest a better way to do this please?


    Reaction

  4. #4
    Fanatic Member
    Join Date
    Feb 2007
    Location
    Eindhoven
    Posts
    828

    Re: [2005] Form Reload in Windows Application

    the closing event is triggered when the form is already being closed so I don't think that using me .close will have any effect in your program.
    I would suggest that you put that code inside a button event instead of closing event of the form.

    vb Code:
    1. private sub button1_click()sender as object, e as eventArgs) Handles button1.click
    2.  
    3. If MessageBox.Show("Do you want to exit application completely?", "Quit Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
    4.             'do nothing
    5.             Application.Exit()
    6.         Else
    7.             'e.Cancel = True
    8.             Me.Close()
    9.         End If
    10. end sub

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Form Reload in Windows Application

    Quote Originally Posted by Reaction
    What I want to do is Unload a Form and then load the forms Parent when the user clicks the Close Button on the form. Problem is I hid the parent form and instead would like to close it, open the child form and when the child form is closed, Open the parent form again as in reload it.
    Can you explain your reasoning for wanting to do that? I can't think of a good reason why that would be required. It sounds like flawed design to me.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2007
    Posts
    134

    Re: [2005] Form Reload in Windows Application

    Thanks. I finally got it fixed. Basically when I open the Child Form using CHILD.SHOW() I can Close the Parent and then when I close the Child I OPen the Parent Form from Scratch and iT fixes the Problem. The Problem was that initially when I was using the Child.ShowDialog(ME), it would not update the List when I closed the Child Form. That was the reason I started searching for a reload method.

    Thanks for the Help. Greatly Appreciated

    Reaction

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