我正在处理一个窗体应用程序,它有两个窗口。在主窗口中,Form1创建了Treatment类的一个实例。我想通过该实例,一旦图像被点击到另一个窗口form2。到目前为止,我有: Form1中:形式c之间传递对象#
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();
}
和窗口2:
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)”
有人能帮助我解决这一问题?
让你的治疗类公共 –
@YograjGupta:这可能不是理想的解决方案,但它会纠正错误。 –