ExRichTextEdit.
本文转载:http://www.csframework.com/archive/2/arc-2-20110830-1816.htm
从网上找来一个扩展的RichTextEdit组件,支持插入图片,格式文本,设置文本底色等操作,只要调用方法即可。
命名空间:Khendys.Controls.ExRichTextEdit
格式化文本及插入图片Demo:
使用方法:
private void menuItem10_Click(object sender, System.EventArgs e)
{
string[] _about = new string[10];
Font[] _fonts = new Font[3];
rtBox_Main.Rtf = "";
_fonts[0] = new Font(FontFamily.GenericSerif, 16f);
_fonts[1] = new Font(FontFamily.GenericSansSerif, 12f);
_fonts[2] = new Font(FontFamily.GenericMonospace, 8f);
_about[0] = "This text and images are ";
_about[1] = "being inserted on the\n";
_about[2] = "Click ";
_about[3] = "event of this menu item.\n\n";
_about[4] = "Sorry I cleared the document, ";
_about[5] = " but just click ";
_about[6] = "undo ";
_about[7] = "and you'll be ok. ";
_about[8] = "\n\nHa Ha! No undo.\n\n";
_about[9] = "Khendys was here ...";
rtBox_Main.InsertTextAsRtf(_about[0], _fonts[0]);
rtBox_Main.InsertTextAsRtf(_about[1], new Font(_fonts[1], FontStyle.Strikeout));
rtBox_Main.InsertTextAsRtf(_about[2], new Font(_fonts[0], FontStyle.Bold | FontStyle.Italic), RtfColor.Olive, RtfColor.Aqua);
rtBox_Main.InsertTextAsRtf(_about[3], new Font(_fonts[1], FontStyle.Italic), RtfColor.Gray);
rtBox_Main.InsertTextAsRtf(_about[4], new Font(_fonts[2], FontStyle.Bold), RtfColor.Red, RtfColor.Yellow);
rtBox_Main.InsertImage(new Bitmap(typeof(RtfInsert), "Smilies.AngrySmile.png"));
rtBox_Main.InsertTextAsRtf(_about[5], _fonts[0]);
rtBox_Main.InsertTextAsRtf(_about[6], _fonts[0], RtfColor.Blue, RtfColor.Aqua);
rtBox_Main.InsertTextAsRtf(_about[7], _fonts[1]);
rtBox_Main.InsertImage(new Bitmap(typeof(RtfInsert), "Smilies.CrySmile.png"));
rtBox_Main.InsertTextAsRtf(_about[8], new Font(_fonts[2], FontStyle.Bold | FontStyle.Italic), RtfColor.Red, RtfColor.Aqua);
rtBox_Main.InsertTextAsRtf(_about[9], new Font(_fonts[1], FontStyle.Italic | FontStyle.Bold | FontStyle.Underline), RtfColor.Black, RtfColor.Red);
rtBox_Main.InsertImage(new Bitmap(typeof(RtfInsert), "Smilies.Beer.png"));
}
命名空间:Khendys.Controls.ExRichTextEdit
格式化文本及插入图片Demo:
使用方法:
private void menuItem10_Click(object sender, System.EventArgs e)
{
string[] _about = new string[10];
Font[] _fonts = new Font[3];
rtBox_Main.Rtf = "";
_fonts[0] = new Font(FontFamily.GenericSerif, 16f);
_fonts[1] = new Font(FontFamily.GenericSansSerif, 12f);
_fonts[2] = new Font(FontFamily.GenericMonospace, 8f);
_about[0] = "This text and images are ";
_about[1] = "being inserted on the\n";
_about[2] = "Click ";
_about[3] = "event of this menu item.\n\n";
_about[4] = "Sorry I cleared the document, ";
_about[5] = " but just click ";
_about[6] = "undo ";
_about[7] = "and you'll be ok. ";
_about[8] = "\n\nHa Ha! No undo.\n\n";
_about[9] = "Khendys was here ...";
rtBox_Main.InsertTextAsRtf(_about[0], _fonts[0]);
rtBox_Main.InsertTextAsRtf(_about[1], new Font(_fonts[1], FontStyle.Strikeout));
rtBox_Main.InsertTextAsRtf(_about[2], new Font(_fonts[0], FontStyle.Bold | FontStyle.Italic), RtfColor.Olive, RtfColor.Aqua);
rtBox_Main.InsertTextAsRtf(_about[3], new Font(_fonts[1], FontStyle.Italic), RtfColor.Gray);
rtBox_Main.InsertTextAsRtf(_about[4], new Font(_fonts[2], FontStyle.Bold), RtfColor.Red, RtfColor.Yellow);
rtBox_Main.InsertImage(new Bitmap(typeof(RtfInsert), "Smilies.AngrySmile.png"));
rtBox_Main.InsertTextAsRtf(_about[5], _fonts[0]);
rtBox_Main.InsertTextAsRtf(_about[6], _fonts[0], RtfColor.Blue, RtfColor.Aqua);
rtBox_Main.InsertTextAsRtf(_about[7], _fonts[1]);
rtBox_Main.InsertImage(new Bitmap(typeof(RtfInsert), "Smilies.CrySmile.png"));
rtBox_Main.InsertTextAsRtf(_about[8], new Font(_fonts[2], FontStyle.Bold | FontStyle.Italic), RtfColor.Red, RtfColor.Aqua);
rtBox_Main.InsertTextAsRtf(_about[9], new Font(_fonts[1], FontStyle.Italic | FontStyle.Bold | FontStyle.Underline), RtfColor.Black, RtfColor.Red);
rtBox_Main.InsertImage(new Bitmap(typeof(RtfInsert), "Smilies.Beer.png"));
}
作者:阿笨
【官方QQ一群:跟着阿笨一起玩NET(已满)】:422315558
【官方QQ二群:跟着阿笨一起玩C#(已满)】:574187616
【官方QQ三群:跟着阿笨一起玩ASP.NET(已满)】:967920586
【官方QQ四群:Asp.Net Core跨平台技术开发(可加入)】:829227829
【官方QQ五群:.NET Core跨平台开发技术(可加入)】:647639415
【网易云课堂】:https://study.163.com/provider/2544628/index.htm?share=2&shareId=2544628
【腾讯课堂】:https://abennet.ke.qq.com
【51CTO学院】:https://edu.51cto.com/sd/66c64
【微信公众号】:微信搜索:跟着阿笨一起玩NET