Link to home
Start Free TrialLog in
Avatar of Tom Sage
Tom SageFlag for United States of America

asked on

.NET WinForms - Program not starting at Form_load event

I am using VS2010 and VB.NET to create a Windows Form program.  When I run it in debug mode it does not start at the Form_Load event.  It seems to start on a Sub.

How can I tell why it is starting on a Subroutine rather than the Form_load event?

Thank you

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

check the startup object in the properties of your project
Avatar of dj_alik
dj_alik

Public Shared Sub Main(ByVal args As String())
Application.Run(New YourForm())
End Sub

Set Your form as Start up Object in Project Properties Window

- Deepak Lakkad

in visual studio, go to Project menu

then click <project-name> Properties (last menu on project's menu.)

and then click on the Application tab on the left panel

then choose your startup form.



Attached screenshot shows what everyone is talking about


ScreenShot005.jpg
Avatar of Tom Sage

ASKER

Thanks to everyone for helping.

I do have the startup object set to Form1.  

If I put a break-point on Form1_Load event and on the FillGrid Subroutine, then press F5.  It breaks at the FillGrid Subroutine.   Very Strange.

I even have the MyApplication_Startup event set to start Form1.

Thanks for any ideas.
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also check that your breakpoint is not disabled for Form Load Event

- Deepak Lakkad
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pressing F11 breaks at the following:

- My.Application_Startup event
        Form1.Show()

Pressing F8 does the following:

- Steps through the Global variables after Public Class Form1 and before the Form1_Load event
- Jumps to the FillGrid Subroutine which is in the Form1 Class

Thanks for any other ideas.

can you show us your code and the image of your application settings?
Sorry, my company will not allow me to display any source code.

I wish I could.

Not all the source code. Just the skeleton code from the form.
I have found the problem by unchecking the Deugging option for Step Over Properties and Operators.

Now I can use F8 to step through all the code.

Thanks to everyone.