richTextBox access from a function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button on a form that calls a function. The function does some stuff
and then I want it to write the results to a richTextBox. The problem is the
code;

richTextBox1.Text += "Results";

Gives me the error, 'Form1.righTextBox1' denotes a field where a class was
expected.

How do I reference the richTextBox from the function?
 
hi Dave
the line MyForm.MyRichTextBox.Text += " more text " ; is no problem with
and should work fine. So , there must be something else causing the
problem and that you need to be looking for. If you still have the problem
would you please post larger snippet of your code may be that would help
figure the problem.
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC
 
I found the problem, I had declared my function as static.

public static void SendRequest( )

it should have been,

public void SendRequest()

That fixed it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top