I’m having some trouble doing a very simple task. I have a rich textbox on my Windows form and I’m trying to access it outside of any button clicks. I’ve realized that the control is not “public” and I can’t just call it in the code where ever I want to change it.
The error I’m getting is: An object reference is required for the non-static field, method, or property.
I know it’s a really novice question but I’ve tried a lot of way to solve this and I cant figure it out. Can someone please help?
The code is
public static void SeeIfFinished()
{
if (FinishedThreadCount == 1)
{
richTextBox1.Text = "text";
}
}
Your method is static – remove the
staticmodifier, and call it by referring to a specific instance of the form:or if your calling code is inside the form class, just: