none
Form Load not firing when form.shown? RRS feed

  • Question

  • When I show particular forms, their load events do not fire.

    I have tried copying all of the code contained within the form to a new version of the form, to no avail.

    I have also tried removing all code from the load event and replacing it with a blank message box, and still nothing happens.

    Please help me!

    Friday, March 15, 2019 11:38 PM

All replies

  • Hello,

    Rather than form load use Form.Shown event. Why use Form.Shown event instead of Form.Load event? Because in some cases code that may be thrown an exception can get a free pass in form load.

    Now with that said, I have no clue to anything pass this as there can be countless reasons what's going on but a best guess is an exception is being thrown. You should really set a breakpoint on the first line of code and step through the code to inspect whatever you have going on and if still unsure you will need to give me more details to what is going on e.g. reading a file, reading a database table, changing a control property etc.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, March 15, 2019 11:43 PM
    Moderator
  • I tried form.shown, but it didn't change anything.

    I have got it working now by putting the form load code into a sub which is activated when a button is clicked to navigate to the form.. Not particularly nice but I've been struggling for hours to find a way around it.

    Saturday, March 16, 2019 12:25 AM
  • I tried form.shown, but it didn't change anything.

    I have got it working now by putting the form load code into a sub which is activated when a button is clicked to navigate to the form.. Not particularly nice but I've been struggling for hours to find a way around it.

    You might try my suggestion of setting a breakpoint which sadly many developers never really learn and they are really great and learning why something is not behaving as expected.

    And this is new, sounds like you are attempting to do something with another form? This is why it's always wise to provide complete details as nobody here are able to guess what you are attempting to do.

    By placing the said into a button is a "work-around" not a solution so if you want real help then you need to provide more details.



    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Saturday, March 16, 2019 1:09 AM
    Moderator
  • Maybe the handler was not properly defined? Usually you should use Form Designer to add it. It looks like this:

    Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

       . . .

    End Sub

    Saturday, March 16, 2019 7:37 AM
  • Hi,

    Do you hide and then show the form? When hiding, the load code is running, you can go to show, it is definitely useless, you either close the form or re-call the load event.

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 19, 2019 9:35 AM
  • When I show particular forms, their load events do not fire.

    I have tried copying all of the code contained within the form to a new version of the form, to no avail.

    I have also tried removing all code from the load event and replacing it with a blank message box, and still nothing happens.

    Please help me!


    Can you show the code that 'shows particular forms'?

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Tuesday, March 19, 2019 4:47 PM