I have two different projects, DriverSide
and LogInForm
. In both of them is a form, in DriverSide
the form Form1
will be executed on the start of the application and in LogInForm
the important form is the UserOnTrip
form. On Form1
is a button and with it´s click event i want to open the UserOnTrip
form, but i dont know how to handle it because the forms are on different projects.
This is my button click method:
private void _btnAccept_Click(object sender, EventArgs e)
{
LogInForm._pnlUserOntrip _pnl = new LogInForm._pnlUserOntrip();
_pnl.Show();
//System.Diagnostics.Process.Start(Application.StartupPath.ToString() + @"\_pnlUserOnTrip.exe");
LogInForm.LoadingScreen _load = new LogInForm.LoadingScreen();
_load.Hide();
}
}
And this is the layout of my solution explorer:
Go to your solution explorer and right click on the project you want to execute. Now click 'Set as start project'. This project gets highlighted then a bit, you should see atleast any difference.
Have a look at this picture . There are the two different projects: John.Socialclub.Data and John.Socialclub.Desktop. And you dont click on any of those files below, right click on of your projects itself and set them simply as start project.
Updated:
So i understood it that way, that you execute in the project DriverSide
the Form1
. On this form you have a button which shell open the form UserOnTrip
which is located in the LogInForm
project.
First of all you want to add a reference to the DriverSide
project. Go once again to the solution explorer and righ click on References
. Then click Add reference
. Then a menu pops up where you select on the left side projects
. Now there should be your project LogInForm
listed, you select it with the comboBox and press OK.
Now we are in the Form1
of DriverSide
:
In the beginning note that you have to add this using
reference to use the reference to the LogInForm
. Add this to the other using references.
using LogInForm;
namespace DriverSide
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void _btnAccept_Click(object sender, EventArgs e)
{
UserOnTrip testWindow = new UserOnTrip();
testWindow.Show();
}
}
}
I just copied your button click method _btnAccept_Click
. Insert this code and you should be fine. You can ignore the constructor public Form1()
, i just placed it in there that you feel familiar with your code and understand exactly where to place what.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.