• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 353
  • Last Modified:

.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

0
Tom Sage
Asked:
Tom Sage
  • 4
  • 3
  • 3
  • +3
3 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
check the startup object in the properties of your project
0
 
dj_alikCommented:
Public Shared Sub Main(ByVal args As String())
Application.Run(New YourForm())
End Sub
0
 
Deepak LakkadCommented:

Set Your form as Start up Object in Project Properties Window

- Deepak Lakkad
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Rose BabuSenior Team ManagerCommented:

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.



0
 
CodeCruiserCommented:
Attached screenshot shows what everyone is talking about


ScreenShot005.jpg
0
 
Tom SageAuthor Commented:
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.
0
 
CodeCruiserCommented:
Where is FillGrid being called? Does the Form1_Load event have a handles clause at the end?
0
 
Deepak LakkadCommented:
Hi

Your Form Load event should have following signature
Private Sub YourForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Open in new window


is it missing "Handles Me.Load"

- Deepak Lakkad
0
 
Deepak LakkadCommented:
Also check that your breakpoint is not disabled for Form Load Event

- Deepak Lakkad
0
 
Éric MoreauSenior .Net ConsultantCommented:
from the IDE, press F11. it will start the debugger stopping on the very first line to be executed. Where is it?
0
 
Tom SageAuthor Commented:
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.

0
 
Éric MoreauSenior .Net ConsultantCommented:
can you show us your code and the image of your application settings?
0
 
Tom SageAuthor Commented:
Sorry, my company will not allow me to display any source code.

I wish I could.

0
 
CodeCruiserCommented:
Not all the source code. Just the skeleton code from the form.
0
 
Tom SageAuthor Commented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now