找传奇、传世资源到传世资源站!

winform中 简洁的html编辑器(支持多种风格皮肤)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

winform中 简洁的html编辑器(支持多种风格皮肤) C#语言基础-第1张using System;using System.Windows.Forms;namespace HtmlEditor{ public partial class Form1 : Form { public Form1() { InitializeComponent(); LoadHtml(this, EventArgs.Empty); styleComboBox.SelectedIndex = 0; } private void UpdateButtons(object sender, EventArgs e) { bold.Checked = htmlEditor.SelectionBold; italic.Checked = htmlEditor.SelectionItalic; underline.Checked = htmlEditor.SelectionUnderline; subscript.Checked = htmlEditor.SelectionSubscript; superscript.Checked = htmlEditor.SelectionSuperscript; if (!string.IsNullOrEmpty(htmlEditor.SelectionFontName)) fontComboBox.Text = htmlEditor.SelectionFontName; if(htmlEditor.SelectionFontSize>0) fontSize.Value = htmlEditor.SelectionFontSize; bUL.Checked = htmlEditor.SelectionBullets; bOL.Checked= htmlEditor.SelectionNumbering; toolStripStatusLabel1.Text = string.Format("SelectionStart: {0} SelectionLength: {1}", htmlEditor.SelectionStart, htmlEditor.SelectionLength); } private void LoadHtml(object sender, EventArgs e) { htmlEditor.BodyHTML = @" <h1>Hello World!</h1> <h2>This is a subtitle</h2> <p> <strong><sup>H</sup><sub>T</sub>ML</strong> <u>example</u> <ul> <li>List element 1</li> <li>List element 2</li> <li>List element 3</li> </ul> </p>"; } private void ShowHtml(object sender, EventArgs e) { MessageBox.Show(htmlEditor.BodyHTML); } private void bold_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionBold = bold.Checked; } private void italic_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionItalic = italic.Checked; } private void underline_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionUnderline = underline.Checked; } private void subscript_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionSubscript = subscript.Checked; } private void superscript_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionSuperscript = superscript.Checked; } private void FindString(object sender, EventArgs e) { htmlEditor.FindString("HTML",true,true); } private void bUndo_Click(object sender, EventArgs e) { htmlEditor.Undo(); } private void bRedo_Click(object sender, EventArgs e) { htmlEditor.Redo(); } private void fontSize_ValueChanged(object sender, EventArgs e) { htmlEditor.SelectionFontSize =(int) fontSize.Value; } private void fontComboBox_Validated(object sender, EventArgs e) { htmlEditor.SelectionFontName = fontComboBox.Text; } private void fontComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (fontComboBox.SelectedItem!=null) htmlEditor.SelectionFontName = fontComboBox.SelectedItem.ToString(); } private void styleComboBox_SelectedIndexChanged(object sender, EventArgs e) { string css; switch (styleComboBox.SelectedIndex) { case 1://Word 2007 css = global::HtmlEditor.Properties.Resources.Office2007; break; case 2://Office 2003 css = global::HtmlEditor.Properties.Resources.Office2003; break; case 3://Wikipedia css = global::HtmlEditor.Properties.Resources.Wikipedia; break; case 4://Google css = global::HtmlEditor.Properties.Resources.Google; break; default: css= string.Empty; break; } htmlEditor.Style =global::HtmlEditor.Properties.Resources.Common css; } private void bOL_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionNumbering = bOL.Checked; } private void bUL_CheckedChanged(object sender, EventArgs e) { htmlEditor.SelectionBullets = bUL.Checked; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复