Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can't passing a parameter WinForm

I’ve an object called "Catalogo" that’s an array of other objects, i use it in Form1 and i wanna use the same instance in Form 2, but I can’t pass it as a parameter, the compiler gives me the error CS0051, but I’m not able to find where I wrong. Can someone help me? That’s my code:

Form1:

public  partial class Form1 :  KryptonForm
    {
       Catalogo  main = new Catalogo();

        public Form1()
        {
            InitializeComponent();
        }


        //when I click the button, create and open a new form2, passing main as a parameter
        private void KryptonButton1_Click(object sender, EventArgs e)
        {
           
            Form2 form2 = new Form2(main);
            form2.Show()
        }




}

Form 2:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

public  partial class Form2 :  KryptonForm
    {
      

        public Form2(Catalogo test)
        {
            InitializeComponent();

        }


}

Catalogo class:

  class Catalogo
  {
     public Catalogo()
     {
      //constructing method
     }

  }

Thanks to anyone who will help me!

>Solution :

Make Catalogo accessible (i.e. public)

public class Catalogo
{
    public Catalogo()
    {
        //constructing method
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading