0

I have a one solution with 3 projects, three windowsforms. I would like to have my main/startup project for form1 and which has 2 buttons. These should start form2/project2 and form3/project3. But how can I do this ??

Nick_BE
  • 127
  • 2
  • 8
  • Marco and CodeCaster gave already the correct answer, but maybe [this answer](http://stackoverflow.com/questions/694730/why-is-set-as-startup-option-stored-in-the-sou-file-and-not-the-sln-file/1808352#1808352) is also valueable for you. – Oliver Nov 15 '11 at 10:27

2 Answers2

2

You could set references to other projects and then try something like this:

Form2 frm2 = new Form2();
frm2.Show();

Form3 frm3 = new Form3();
frm3.Show();

or

YourClass2 cls2 = new YourClass2();
// Do what you need with it
Marco
  • 56,740
  • 14
  • 129
  • 152
0

Add a reference to Project2 and Project3 to Project1, then you can use the public classes from those projects.

private void Form1Button1_Click(object sender, EventArgs e)
{
    var newForm = new Project2.Form2();
    newForm.Show(); // or ShowDialog to block
}
CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • Is it also possible to show these project.forms in a tabcontrol in the mainproject by any chance ? – Nick_BE Nov 15 '11 at 10:14
  • @Nick_BE: don't use forms for that, but convert them to UserControls so you can include them everywhere! – Marco Nov 15 '11 at 10:16
  • Parhaps, if you set [`TopLevel`](http://msdn.microsoft.com/en-us/library/system.windows.forms.form.toplevel.aspx) to `false`. But why would you do that? Creating a user control would indeed be the better option. If you need it somewhere 'standalone', you simply put it on a form. – CodeCaster Nov 15 '11 at 10:18