Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 248
  • Last Modified:

Accessing a component on the main form from a class.

Hi,

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]; <======
                        break;
                }
           
            }

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

        private void lstvFoodDB_AfterSelect(object sender, TreeViewEventArgs e)
        {
            DataClass.GetDisplayText((DataRow)e.Node.Tag);
        }

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...

Pete
0
peterkiers
Asked:
peterkiers
1 Solution
 
Imran Javed ZiaCommented:
Just make a public property in MainForm for Textbox and then you will be able to access that with form object
0
 
peterkiersAuthor Commented:
oke thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now