Static Public Void Function -- Cannot reference textBox.text

I have a form that is separate from the main form and I want to have a public function within that form that will refresh all of the textBox elements on the form.

However when I try to put textBox1.text = newValue in the static public function, the textBox1 element is an error how can i reference the local elements from a public form?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The problem is the static delaration of the function.  If you are going to have an instance of the form then it does not necessarily have to be static.

What you could try is sending an event to the form instead of calling the public method such as from the main form:

Or you could create an event on your main and listen for the event in your other form.

I dont get exactly what your problem is.

But i think you are not able to access a textbox in form1, within a function in form1.
If that is the problem,

Then i think, you are not able to access textbox because your function is a static public function.
Static public function can only access static variables.
So, if your textbox is static, then only u will be able to use the textbox in your static public function.

Hope this will be useful.
Good luck.
Just remove the "static" part of the function declaration. Then call it like this: form.MyFunc();
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Rowdyone52Author Commented:
If static isnt in the declaration, the Function doesnt show up as a available function.

Are you calling the child form from the "Main" function?  Static methods may only call other static methods.  You may call the child form form the main form in the main form's load event.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HI Rowdy,

Suppose u have a class called a.cs
In which you have a function called yourFunction() like this,

public void yourFunction()
// do ur work

Then wherever you want to use the function, first of all create an object of class a, like this,
a myObject = new a();
and then call,

Hope this will be useful.
Good luck.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

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.