Accessing a component on the main form from a class.


I have a main form called MainForm and a class called ProductDatabase.

In the class i have the following methode:

                 public GetDisplayText(DataRow row)
                switch (row.Table.TableName)
                    case Tables.Product:
                        MainForm.txtFoodName.text  = "" + row[ProductField.Name]; <======

And the methode in the MainForm that calls the methode of the class looks like this:

        private void lstvFoodDB_AfterSelect(object sender, TreeViewEventArgs e)

But the methode that i have marked with the arrow doesn't work, because i can't get
access to the component txtFoodName on the MainForm.

Who knows the answer and is willing to help me...

Who is Participating?
Imran Javed ZiaConnect With a Mentor Consultant Software Engineer - .NET ArchitectCommented:
Just make a public property in MainForm for Textbox and then you will be able to access that with form object
peterkiersAuthor Commented:
oke thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.