0

Hi guys..
I have some problem with Richtextbox. I have a Richtextbox in Form class. How can I add any text into the textbox from other classes for instance from Client class? Hope you can help me.

Thanks

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by daksein
0

DO:

//on main form:
void OpenClient()
{
    Client c = new Client(this);
    c.DoWork();
}

public void AddText(string text)
{
    this.richTextBox1.AppendText(text+Environment.NewLine);
}

//on client class:
class Client
{
    MainForm mf;
    public Client(MainForm _mf)
    {
        this.mf = _mf;
    }

    public DoWork()
    {
        string text = "";
        //do some work ... and add value to text field;
        //and pass to rtb on main form:
        mf.AddText(text);
    }
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.