日期:2014-05-18  浏览次数:21167 次

想在winforms 下实现富文本的编辑,如设置字体颜色、粗细等等,并保存到数据库中该如何实现呢?
想在winforms 下实现富文本的编辑,如设置字体颜色、粗细等等,并保存到数据库中该如何实现呢?

------解决方案--------------------
RTF
------解决方案--------------------
RichTextBox,保存RichTextFormat格式文本。
------解决方案--------------------
private void 粗体BtoolStripButton_Click(object sender, EventArgs e)
{
if (富文本编辑.SelectedText != "") 富文本编辑.SelectionFont = new Font("Tahoma", 10, FontStyle.Bold);
else 富文本编辑.Font = new Font("Tahoma", 10, FontStyle.Bold);
}

private void 斜体ItoolStripButton_Click(object sender, EventArgs e)
{
if (富文本编辑.SelectedText != "") 富文本编辑.SelectionFont = new Font("Tahoma", 10, FontStyle.Italic);
else 富文本编辑.Font = new Font("Tahoma", 10, FontStyle.Italic);
}

private void 字体toolStripButton_Click(object sender, EventArgs e)
{
选字体.ShowDialog();
选字体.AllowVerticalFonts = true;
选字体.FixedPitchOnly = true;
选字体.ShowApply = true;
选字体.ShowEffects = true;
if (富文本编辑.SelectedText == "")富文本编辑.Font = 选字体.Font;
else 富文本编辑.SelectionFont = 选字体.Font;
}