I have adapted the code from winforms html editor to C# (see below). Is it possible to use the CKEditor instead?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WebEditorTest
{
/// <summary>
/// https://stackoverflow.com/questions/214124/winforms-html-editor
/// </summary>
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("about:blank");
Application.DoEvents();
webBrowser1.Document.OpenNew(false).Write("<html><body><div id=\"editable\">Edit this text</div></body></html>");
foreach (HtmlElement el in webBrowser1.Document.All)
{
el.SetAttribute("unselectable", "on");
el.SetAttribute("contenteditable", "false");
}
foreach (HtmlElement el in webBrowser1.Document.All.GetElementsByName("editable"))
{
el.SetAttribute("width", webBrowser1.Width + "px");
el.SetAttribute("height", "100%");
el.SetAttribute("contenteditable", "true");
}
webBrowser1.Document.DomDocument.GetType().GetProperty("designMode").SetValue(webBrowser1.Document.DomDocument, "on", null);
webBrowser1.IsWebBrowserContextMenuEnabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
textBoxMarkup.Text = webBrowser1.DocumentText;
}
}
}