Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, May 8, 2016 3:51 PM
i have one form "Form 1",and i when i add new item login form " form2"
i try this code
in second form 2:"login form 2 "
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
new Form1().Show();
this.Hide();
}
}
}
but still the first form who it start first instead login form2
how change priorité?
All replies (3)
Sunday, May 8, 2016 8:18 PM ✅Answered
Hi foxnight,
Maybe these steps can be helpful for you...
Set the startup form in Windows Forms:
- In Solution Explorer, right-click the project and choose Properties. The Project property page opens with the General properties displayed.
- Choose the form you want as the startup form from the Startup Object drop-down list.
Official MSDN documentation about this: https://msdn.microsoft.com/en-us/library/aa984318(v=vs.71).aspx
Or you can do it with code like this:
// ... other code
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); // Set your startup form here
}
// ... other code
Hope this was helpful for you..
Best regards!
(If this was helpful for you, vote for it and propose it as an answer)
Sunday, May 8, 2016 6:14 PM
if you are talking about the first form to display in Windows Form application, it is set in the program.cs file. Such as Application.Run( new Form2());
Sunday, May 8, 2016 6:16 PM
In order to specify the first form, go to Program.cs file (which can be found in Solution Explorer), and change Form1 to Form2.