Refreshing the richtextbox and clearing if of the back color so it displays a new white page

469 views Asked by At

I have a rtbDoc(simple word app)that you can change the back color using the colorDialog, it does not change the color back to white if you load a new doc, so the color you picked stays the same, how would i make it refresh every time you load a new Doc ?

Here is what i have for the Back color

try
        {
            colorDialog1.Color = rtbDoc.BackColor;
            {
                if (colorDialog1.ShowDialog() == DialogResult.OK)
                {
                    rtbDoc.BackColor = colorDialog1.Color;
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message.ToString(), "Error");
        }

And here is the code for the New button

      if (rtbDoc.Modified == true)
            {
                DialogResult answer;
                answer = MessageBox.Show("Save Document before creating a new document?", "Unsaved Document",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (answer == DialogResult.No)
                {
                    currentFile = "";
                    this.Text = "Editor: New Document";
                    rtbDoc.Modified = false;
                    rtbDoc.Clear();
                    return;
                }
                else
                {

                    saveToolStripMenuItem_Click(this, new EventArgs());
                    rtbDoc.Modified = false;
                    rtbDoc.Clear();
                    currentFile = "";
                    this.Text = "New Document";
                    return;
                }
            }
            else
            {
                currentFile = "";
                this.Text = "New Document";
                rtbDoc.Modified = false;
                rtbDoc.Clear();
                return;
            }

Or is it some thing i should change in the formLoad event ?

1

There are 1 answers

1
Farid Movsumov On

Add this code where you open new document.

rtbDoc.BackColor = Color.White;