CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Location
    Australia, Yeppoon
    Posts
    44

    Talking How do you reload a form?

    Hey I got a real noob question for yahs , I have just never had to do it. I need to know how to reload a form so that all its values are set back to the time it was originally loaded.
    Thanks heaps in advance.

  2. #2
    Join Date
    Sep 2004
    Location
    Sandhem, Sweden
    Posts
    20

    Re: How do you reload a form?

    Hi.

    Try to do the following from another form or module:

    Code:
    Unload frmMyForm
    frmMyForm.Show
    It should work.

    Regards,
    Michael

  3. #3
    Join Date
    Oct 2004
    Location
    Australia, Yeppoon
    Posts
    44

    Unhappy Re: How do you reload a form?

    Yeah I tried that and instead of the .show I used .visible = true, but both dont actually do all the commands within the form load.
    I dont get why that doesn't work because it is logical that it would close down the form and "HAVE TO" reload it and therefore re do the code in the Form_load. But it doesn' seem to, please I really need to know how to overcome this problem. Thanks for your help though Micheal

  4. #4
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: How do you reload a form?

    Following code does NOT call Form_Initialize, but calls Form_QueryUnload, Form_Unload, Form_Load (generated by Unload & Load) and all other events generated by Show() method:
    Code:
    Sub reloadForm(frm As Form)
        Unload frm
        Load frm
        frm.Show
    End Sub
    Best regards,
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

  5. #5
    Join Date
    Oct 2004
    Location
    Australia, Yeppoon
    Posts
    44

    Re: How do you reload a form?

    Thanks heaps hey, the code

    Unload frm
    Load frm
    frm.Show

    worked. But I just dont understand what the difference is between
    Unload frm
    Load frm
    frm.Show

    and just

    Unload frm
    Load frm

  6. #6
    Join Date
    Aug 2004
    Location
    Bucharest, Romania... sometimes
    Posts
    1,039

    Re: How do you reload a form?

    If you don't call Unload, then Load will be ignored. So, you must call Unload before, and that also means closing the form. Load call doesn't bring back the window for you, thus you have to call Show, to make the form visible again.
    If you'd like to understand more about the events generated, create a test project and put message boxes or log in a file all the events of a form object. Then, play around with that form and try calling all it's methods, plus load & unload. Study the dumped log to understand when each event is generated.
    I can assure you that will be useful information.
    Regards,
    Bogdan Apostol
    ESRI Developer Network

    Compilers demystified - Function pointers in Visual Basic 6.0
    Enables the use of function pointers in VB6 and shows how to embed native code in a VB application.

    Customize your R2H
    The unofficial board dedicated to ASUS R2H UMPC owners.

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