Winform Html Editor 使用kindeditor组件实现winform Html 编辑器
Winform Html Editor 使用kindeditor组件实现winform Html 编辑器
C# Code:
public partial class Form1 : Form
{
string content = "";
public Form1()
{
InitializeComponent();
this.webBrowser1.Url = new System.Uri(Application.StartupPath "\\kindeditor\\e.html", System.UriKind.Absolute);
this.webBrowser1.ObjectForScripting = this;
}
//设置webBrowser1.ObjectForScripting属性才会调用此方法
public void RequestContent(string str)
{
content = str;
txtHTML.Text = content;
//CS平台使用此方法给文本控件赋值
//this.SetEditorBingingValue(txtHTML,content,true);
richTextBox1.Text = content;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (txtHTML.Focused)
{
content = txtHTML.Text;
SetDetailContent();
}
}
private void richTextBox1_TextChanged_1(object sender, EventArgs e)
{
if (richTextBox1.Focused)
{
content = richTextBox1.Text;
SetDetailContent();
}
}
public void SetDetailContent()
{
webBrowser1.Document.InvokeScript("setContent", new object[] { content });
}
public string GetContent()
{
return content;
}
private void webBrowser1_Resize(object sender, EventArgs e)
{
this.webBrowser1.Refresh();
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
public partial class Form1 : Form
{
string content = "";
public Form1()
{
InitializeComponent();
this.webBrowser1.Url = new System.Uri(Application.StartupPath "\\kindeditor\\e.html", System.UriKind.Absolute);
this.webBrowser1.ObjectForScripting = this;
}
//设置webBrowser1.ObjectForScripting属性才会调用此方法
public void RequestContent(string str)
{
content = str;
txtHTML.Text = content;
//CS平台使用此方法给文本控件赋值
//this.SetEditorBingingValue(txtHTML,content,true);
richTextBox1.Text = content;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
if (txtHTML.Focused)
{
content = txtHTML.Text;
SetDetailContent();
}
}
private void richTextBox1_TextChanged_1(object sender, EventArgs e)
{
if (richTextBox1.Focused)
{
content = richTextBox1.Text;
SetDetailContent();
}
}
public void SetDetailContent()
{
webBrowser1.Document.InvokeScript("setContent", new object[] { content });
}
public string GetContent()
{
return content;
}
private void webBrowser1_Resize(object sender, EventArgs e)
{
this.webBrowser1.Refresh();
}
}
//来源:C/S框架网(www.csframework.com) QQ:1980854898
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网