I am working on a form application that has two windows. In the main window, Form1 I create an instance of the class Treatment. I would like to pass that instance, once a image is clicked to the other window form2. So far I have:
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();
}
and in form2:
public partial class Form2 : Form
{
private Treatment treatment;
public Form2()
{
InitializeComponent();
}
public Form2(Treatment treatment)
{
InitializeComponent();
this.treatment = treatment;
}
}
}
I get 1 error : Error 1 Inconsistent accessibility: parameter type ‘WasteTreatment.Treatment’ is less accessible than method ‘WasteTreatment.Form2.Form2(WasteTreatment.Treatment)’
Someone can help me to fix this?
private Treatment treatmentcan only be used withinForm1, because you have marked itprivate.I think the best way to correct the problem is something like this:
and you can make
wirelessResultandidprivate members ofForm1.