我有一个rtbDoc(简单的单词应用程序),您可以使用colorDialog更改背面颜色, 如果您加载新文档,它不会将颜色更改为白色,因此您选择的颜色保持不变,每次加载新文档时如何刷新?
以下是我对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");
}
这是New按钮的代码
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事件中更改某些内容吗?
答案 0 :(得分:2)
在打开新文档的位置添加此代码。
rtbDoc.BackColor = Color.White;