Creating HTML Editor in C#.net Windows Application
1. Create a Windows Application Project and add a form
2. Add the Web Browser control to the Form
3. Add a reference to mshtml
using mshtml;
4. On Form Load add this code
Editor.DocumentText = "<html><body><div></div></body></html>";
doc = Editor.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
5. Basic editing operations can be performed using execCommand
eg: webBrowser.Document.ExecCommand("Bold", false, null);
6. To eanble editing use this code
private void Editor_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (Editor.Version.Major >= 9)
{
Editor.Document.Write(Editor.DocumentText);
doc.designMode = "On";
}
}
1. Create a Windows Application Project and add a form
2. Add the Web Browser control to the Form
3. Add a reference to mshtml
using mshtml;
4. On Form Load add this code
Editor.DocumentText = "<html><body><div></div></body></html>";
doc = Editor.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
5. Basic editing operations can be performed using execCommand
eg: webBrowser.Document.ExecCommand("Bold", false, null);
6. To eanble editing use this code
private void Editor_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (Editor.Version.Major >= 9)
{
Editor.Document.Write(Editor.DocumentText);
doc.designMode = "On";
}
}
No comments:
Post a Comment