1

我有一个 rtbDoc(简单字应用程序),您可以使用 colorDialog 更改背景颜色,如果您加载新文档,它不会将颜色更改回白色,所以您选择的颜色保持不变,我将如何制作它每次加载新文档时刷新?

这是我的背景颜色

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

这是新建按钮的代码

      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;
            }

还是我应该在 formLoad 事件中更改一些东西?

4

1 回答 1

2

在您打开新文档的位置添加此代码。

rtbDoc.BackColor = Color.White;
于 2012-01-16T15:18:47.083 回答