【问题标题】:Refreshing the richtextbox and clearing if of the back color so it displays a new white page刷新richtextbox并清除背景颜色,以便显示新的白页
【发布时间】:2012-02-11 09:08:52
【问题描述】:

我有一个 rtbDoc(simple word app),您可以使用 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 事件中改变什么?

【问题讨论】:

    标签: c# project word-processor colordialog


    【解决方案1】:

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

    rtbDoc.BackColor = Color.White;
    

    【讨论】:

    • 它可以工作,但必须将其放入frmMain_Load,否则什么都不会发生,但它可以工作
    猜你喜欢
    • 1970-01-01
    • 2015-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    • 2011-10-17
    相关资源
    最近更新 更多