我有一个 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 事件中更改一些东西?