Question not all forms listed in startup form dropdown

kpgraci

Active member
Joined
Feb 21, 2011
Messages
30
Location
New Orleans
Programming Experience
10+
Hi all,

I have a project with 7 forms. I wanted to change the startup form for testing, but in the project properties application tab under startup form, only 3 of my forms show up as available.

So I manually edited the Application.myapp file and changed the MainForm tag to frmSearch.

I checked the property pages and now frmSearch is listed in the dropdown, and it is selected.

Run I compile I get an error:

Error 1 'frmSearch' is a type in 'MyTestApp' and cannot be used as an expression. C:\Documents and Settings\...\My Project\Application.Designer.vb 35 27 MyTestApp

frmSearch is a form, just like other forms that work as the startup form.

What's going on here?
 
Could you attach a sample project that reproduces the problem of a form not being listed in Startup Form list? Just the project source (zip it), not Bin/Obj folders.
 
The forms that is not listed has constructors that requires parameters, but no parameterless constructor. The application framework requires using the parameterless constructor when creating the main form instance, therefore they are not listed.

To resolve, (A) add a parameterless constructor, or (B) don't use them as startup forms, or (C) go to application events and override OnRun where you create the form with relevant arguments and assign to MainForm before the base call, or (D) disable application framework (and lose other benefits of it) and set up your own Sub Main where you create the instance with the relevant arguments. Option C will not behave well if a splash screen is used.

My suggestion to those options is, do option A, where you can optionally call the constructor that has parameters with your default arguments. If such constructor should not be exposed when released you can use #If DEBUG conditional compilation to leave that out then (and not use that as startup form then).
So I manually edited the Application.myapp file and changed the MainForm tag to frmSearch.
A comment about this, don't manually edit designer generated files.
 
Back
Top