我正在开发一个有两个窗口的表单应用程序。在主窗口中,我在 Form1 中创建了 Treatment 类的实例。我想传递那个实例,一旦图像被点击到另一个窗口 form2。到目前为止,我有: Form1:
public partial class Form1 : Form
{
private Treatment treatment;
//method where i inistantiate the treatment
private void processTreatment(int id, Button button)
{
treatment = new Treatment(wirelessResult, id);
Alarm alarm = new Alarm(count, treatment);
wirelessResult.GenerateNumber();
alarm.setColor();
events.add(alarm);
if (getResult(treatment) == true)
{
storeSuccess(button);
}
else if (getResult(treatment) == false)
{
storeFailed(button);
}
}
// image clicked
private void treatmentStation1_Click(object sender, EventArgs e)
{
Form2 secondForm = new Form2(treatment);
secondForm.Show();
}
在form2中:
public partial class Form2 : Form
{
private Treatment treatment;
public Form2()
{
InitializeComponent();
}
public Form2(Treatment treatment)
{
InitializeComponent();
this.treatment = treatment;
}
}
}
我收到 1 个错误:错误 1 可访问性不一致:参数类型“WasteTreatment.Treatment”比方法“WasteTreatment.Form2.Form2(WasteTreatment.Treatment)”更难访问
有人可以帮我解决这个问题吗?