Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
does anybody can help about this?
i had a windows form application with some controls and code to run...by the way.
when i run my project,the form1 will appear.ok.
And now i create second form for control user access with 2 text boxes and a button.
i want to run form2 before form1 when i run my projct.is it possible?
Posted

You need to either run form2 from the constructor of form 1, or change what is the startup form for your project. The constructor does not show the form, various events need to occur, and if you run form2 in the constructor, it will run first.
 
Share this answer
 
Comments
Maciej Los 24-Aug-12 14:28pm    
Yes! +5
FM7 24-Aug-12 14:29pm    
Thanks.how?
Christian Graus 24-Aug-12 14:35pm    
Exactly what I said. In the constructor for Form1, show Form2.
Maciej Los 24-Aug-12 14:39pm    
I got MS VS for VB. So, the method could be differ...
Go to the start of Form1 class module. Above the code window, you can find 2 comboboxes. First with text: "Form1" and the second with: "Declarations". Find the New() procedure in the second combobox. More at http://msdn.microsoft.com/en-us/library/system.windows.forms.form.form%28v=vs.71%29.aspx
FM7 24-Aug-12 14:34pm    
how to change the startup form for my project?
In program.cs, change the Application.Run(...). So you can handle your startup form in entry point [static void Main()]

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());//here you change your form
}


Hope this help.
cheers
 
Share this answer
 
v2
Comments
FM7 24-Aug-12 14:37pm    
thanks.usefull.
5 thanks
RaisKazi 24-Aug-12 14:44pm    
My 5.
this is just as it..
C#
public Form1()
{
    InitializeComponent();
    Application.Run(new Form2());
}
 
Share this answer
 
Comments
RaisKazi 24-Aug-12 14:44pm    
My 5.
FM7 24-Aug-12 14:47pm    
5.thanks
ridoy 24-Aug-12 14:53pm    
welcome and also thanks RaisKazi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900