Results 1 to 3 of 3

Thread: Which is the best practice to reload a form?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2013

    Which is the best practice to reload a form?


    I have a form that has two modes; Online and Offline. The default mode is Online. There are two radio buttons in that form for the user to chose from in order to switch modes. In the radio button's CheckedChanged event I change the mode flag and reload the form so Form_load event's contents executed again with a different mode flag.

    I have two choices to do that:

    1. Move all Form_load's contents to a separate Sub and call that sub from the radio button's CheckedChanged event.
    2. Just call Form_load like this: Form1_Load(sender, e) from the radio button's CheckedChanged event.

    Which is good and which is bad? I mean, for the sake of speed, resources, memory leaks... or are they both bad?

    Thank you.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002

    Re: Which is the best practice to reload a form?

    The first one is always better. It's far more maintainable. If you ever change your design such that the load did some unique things that didn't make sense for the change, then you'd have to go to that first method anyways.
    My usual boring signature: Nothing

  3. #3
    Frenzied Member jdc20181's Avatar
    Join Date
    Oct 2015

    Re: Which is the best practice to reload a form?

    Def. put it in a sub, and call it, do not try to call form load events if the form is already loaded. I put everything in subs by themselves now anyways, as then I can reuse them elsewhere without repeating code.
    Disclaimer: When code is given for example - it is merely a example.
    See my browser project BeffsBrowser
    Try my new Browser project LightBrowse "A Browser and not much else" Screen Capture with Imgur API

    Unless said otherwise (e.g. From one of my projects thus, those are mostly licensed under MIT) - All Code snippets advice or otherwise that I post on this site, are expressly licensed under Creative Commons Attribution 4.0 International Please respect my copyrights.

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