blah blah blah is here! blah blah » Close

up0down
link

I am trying to make a fullscreen text editor. I want the user to be able to change the background color of the richtextbox on form1 by changing settings on a second form, settingsForm. I can't figure out how to access and change the richtextbox's background color on Form1 from the second form without creating a new instance of Form1.

last answered 2 years ago

1 answers

up0down
link

Try something like this (use actual control names for Form1 and richTextBox1):
Form1 f1 = (Form1)Application.OpenForms["Form1"];
RichTextBox rtb = (RichTextBox)f1.Controls["richTextBox1"];
rtb.BackColor = Color.Red; // or whatever

up0down
link

Thank you so much! This had been frustrating me for days.

This post was imported from csharpfriends, if you have a similiar question please ask it again.

All previous members have been migrated, hope you enjoy the new platform!

Feedback