Ale TheFe Ale TheFe - 3 months ago 21
C# Question

How to write to a textbox that is in another Form?

I have a .NET application which has 2 forms: inside Form1 there is all the application stuff, while inside LogForm there is only a readonly textbox. I want to print some text to this textbox inside LogForm from Form1, while Form1 is performing all the work.

I open my LogForm via the

LogForm logForm = new LogForm();
logForm.Show();


But then? How can I do that?

Answer Source

You must have the reference to this TextBox.

Put your access modifier to public in your visual studio form designer and access your TextBox by logForm1.YourTextBox.Text += "new line \r\n";