基本信息
源码名称:WinformHTMLEditor winform 富文本编辑器
源码大小:0.70M
文件格式:.rar
开发语言:C#
更新时间:2020-07-21
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

基于kindeditor


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WinformHTMLEditor
{
    [ComVisible(true)]
    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();
        }

     
    }
}