Winform Html Editor 使用kindeditor组件实现winform Html 编辑器
作者:C/S框架网  发布日期:2017-03-24 21:01:19
  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



点击下载附件 点击下载附件 (如下载失败,请邮件通知我们寄回给您,或QQ:23404761留言.)
上一篇 下一篇