目前我正在保存富文本框的内容:
private void asRTFToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFile1 = new SaveFileDialog();
saveFile1.DefaultExt = "*.rtf";
saveFile1.Filter = "RTF Files|*.rtf|TXT Files|*.txt";
if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
saveFile1.FileName.Length > 0)
{
telep.SaveFile(saveFile1.FileName, RichTextBoxStreamType.RichText);
}
}
将其加载为:
private void rTFToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFile1 = new OpenFileDialog();
openFile1.DefaultExt = "*.rtf";
openFile1.Filter = "RTF Files|*.rtf";
if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
openFile1.FileName.Length > 0)
{
telep.LoadFile(openFile1.FileName, RichTextBoxStreamType.RichText);
}
}
如何保存和加载富文本框的背景颜色?
答案 0 :(得分:0)
尝试使用registery
`private void SaveSettings()
{
RegistryKey R = Registry.CurrentUser.CreateSubKey("RTF box");
R.SetValue("FontName", textBox1.Font.FontFamily.GetName(0));
R.SetValue("FontSize", Convert.ToString(textBox1.Font.Size));
R.SetValue("ForeCol", Convert.ToString(textBox1.ForeColor.ToArgb()));
R.SetValue("BackCol", Convert.ToString(textBox1.BackColor.ToArgb()));
R.SetValue("WordWrap", Convert.ToString(textBox1.WordWrap));
}`
而不是文本框使用富文本框的功能