Learn how to a build a cloud-first strategyRegister Now

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

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

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
peterkiersAuthor Commented:
oke thanks

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