Click here to Skip to main content
Click here to Skip to main content

Zeta HTML Edit Control

, 9 Jul 2013
Rate this:
Please Sign up or sign in to vote.
A small wrapper class around the Windows Forms 2.0 WebBrowser control

Introduction 

This article presents you a small wrapper class around the Windows Forms 2.0 WebBrowser control.

Features

The wrapper is no rocket science but provides some features I struggled with in the past. We use the control in several of our own (internal and external) applications, e.g. our Test Management tool

Some of the features include:

  • Enable the setting of text even when the control is not yet fully initialized
  • Allow pasting of images from the clipboard
  • Allows for resizing the images within the editor with the mouse 
  • Provide an alternative context menu for applying formatting options
  • Optionally directly edit the underlying HTML source code
  • Translated resources in English and German
  • Interface IExternalInformationProvider for externally persisting and restoring settings
  • Provide standard CSS in the control; usually you do not need to define your own CSS

Using the Code

To include the code in your own project, simply include the "ZetaHtmlEditControl.dll" assembly into your project.

Add the assembly to your Visual Studio .NET 2008 Windows Forms Designer Toolbox if you want to be able to drag the ExtendedWebBrowser control to your forms. Alternatively create and initialize an instance of the ExtendedWebBrowser control by code.

Setting HTML

To put HTML from your code into the control, assign the HTML code to the ExtendedWebBrowser.DocumentText property. You do not have to pass a complete HTML document with HEAD and BODY tags but only the actual content that you would write inside the BODY tag.

Getting the HTML 

To read out the HTML from the control, call the ExtendedWebBrowser.GetDocumentText(string folderPath) method. The method takes one parameter "folderPath" that tells the control where to store newly passed images from the clipboard. 

Summary

This article quickly introduced a wrapper around the Windows Forms 2.0 WebBrowser control that adds some extra functions to make it more usable in a real-world-application. Feel free to copy, modify or extend the control to match your own requirements.

To ask questions, suggest features or provide other comments, please use the comments section at the bottom of this article.

History

  • 2013-07-09 - You now also find the project on GitHub
  • 2013-05-20 - Images inside the edit control can now be resized proportionally to make them smaller. When persisting the images, they are actually resized on disk, too.
  • 2011-06-02 - Added support for inserting and editing tables. Added new user control that has a toolbar (see screenshot) that you can switch on and off from code.
  • 2011-03-16 - Updated for and tested with the latest Internet Explorer 9 (RTM). If you do experience AccessViolation exceptions when working with this control, please read this MSDN blog posting that suggests to add a custom build step
    "$(DevEnvDir)..\tools\vsvars32.bat"
    editbin.exe /NXCOMPAT:NO "$(TargetPath)"
  • 2011-02-26 - Update to (hopefully) make the control work with Internet Explorer 9 RC work again. See this Stack Overflow posting for details. I've included a mini web server with the control to serve the texts from this server, instead of setting it directly. It should be 100% transparent to the user of the code.
  • 2009-11-18 - First public release to CodeProject.com

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Uwe Keim
Chief Technology Officer Zeta Producer Desktop CMS
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.
 
In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.
 
Some cool, free software from us:
 
Free Test Management Software - Intuitive, competitive, Test Plans. Download now!  
Homepage erstellen - Intuitive, very easy to use. Download now!  
Send large Files online for free by Email
Offline-Homepage-Baukasten

Comments and Discussions

 
QuestionCan't add to toolbox in VS2012 PinmemberDaniel Borson31-Jan-14 11:37 
QuestionNot working in vs2013 Pinmembersimplex223-Nov-13 11:42 
GeneralRe: Not working in vs2013 Pinmemberstelios198419-May-14 2:49 
QuestionSpell check PinmemberMember 1039935913-Nov-13 5:16 
QuestionDisabling shortcuts Alt + a etc. PinmemberMember 81657438-Oct-13 22:15 
QuestionMaking it readonly without disabling scrollbars PinmemberMember 99171342-Sep-13 18:52 
QuestionHow to save html from HtmlEditUserControl1 to file Pinmemberelpaez17-Aug-13 1:50 
AnswerRe: How to save html from HtmlEditUserControl1 to file PinmemberMember 99171342-Sep-13 19:13 
GeneralRe: How to save html from HtmlEditUserControl1 to file Pinmemberelpaez2-Sep-13 19:59 
GeneralMy vote of 5 PinmemberDanilo Dev.8-Jul-13 3:57 
QuestionI added Font Name and Size Pinmemberndennisv11-Jun-13 3:29 
QuestionReally nice but where is the font and font size? Pinmemberndennisv10-Jun-13 8:08 
GeneralMy vote of 4 PinmemberJunRui1-Jun-13 6:21 
QuestionLove it... PinmemberOleg Shilo21-May-13 2:43 
AnswerRe: Love it... PinsitebuilderUwe Keim21-May-13 3:39 
GeneralRe: Love it... PinmemberOleg Shilo21-May-13 3:56 
GeneralRe: Love it... PinmemberOleg Shilo21-May-13 21:02 
GeneralRe: Love it... PinsitebuilderUwe Keim21-May-13 21:48 
GeneralRe: Love it... PinmemberOleg Shilo21-May-13 21:59 
GeneralRe: Love it... PinmemberOleg Shilo26-May-13 2:29 
GeneralMy vote of 5 Pinmembersha-pro20-May-13 19:53 
GeneralMy vote of 5 PinmemberPolinia20-May-13 2:06 
QuestionMethodAccessException [modified] PinmemberGrizaster14-Feb-13 4:10 
AnswerRe: MethodAccessException PinsitebuilderUwe Keim14-Feb-13 5:20 
GeneralRe: MethodAccessException PinmemberGrizaster14-Feb-13 21:13 
GeneralRe: MethodAccessException PinsitebuilderUwe Keim14-Feb-13 23:04 
GeneralRe: MethodAccessException PinmemberGrizaster15-Feb-13 0:06 
GeneralRe: MethodAccessException Pinmemberiam_xor27-May-13 17:25 
QuestionException thrown when deleting all text in the source editor PinmemberMember 398234515-Jan-13 15:03 
AnswerRe: Exception thrown when deleting all text in the source editor PinsitebuilderUwe Keim15-Jan-13 18:36 
Questionspecial character Pinmembersir_Arthur300013-Dec-12 6:12 
QuestionSpecial characters Pinmembercomtric22-Oct-12 2:56 
AnswerRe: Special characters Pinmembersir_Arthur300013-Dec-12 6:14 
GeneralRe: Special characters Pinmembercomtric14-Dec-12 1:23 
GeneralRe: Special characters Pinmembergiova28-Mar-13 10:47 
QuestionHow we can change font? Pinmemberkaramih3-Oct-12 10:08 
GeneralMy vote of 5 PinmemberEngone14-Dec-11 9:40 
QuestionFont Change PinmemberezbUltra3-Nov-11 0:30 
QuestionAssembly load issue PinmemberEric Legault13-Oct-11 5:51 
AnswerRe: Assembly load issue PinsitebuilderUwe Keim13-Oct-11 6:43 
Question2 Questions (httpserver.dll) PinmemberMartin Poehler21-Jul-11 5:21 
AnswerRe: 2 Questions (httpserver.dll) PinsitebuilderUwe Keim22-Jul-11 21:29 
Hi Martin
 
Regarding 1.) Please see webserver.codeplex.com [^] for the original article of the web server.
 
Regarding 2.) The whole purpose of the article is to provide an HTML editor. If you do need an HTML viewer, simply use the built-in class [^] of Windows Forms.
Wollen Sie ganz einfach Ihre eigene Homepage erstellen, ohne HTML-Kenntnisse, einfach, professionell und mit viel Freude? Probieren Sie unser Desktop Content Management System (CMS) Zeta Producer für Windows aus. Komplett mit eigenem Shop, Gästebuch, Weblog, Bildergalerien, Integration von YouTube-Videos. Wir haben eine aktive Anwender-Community, schnellen Support, sympathische Support-Mitarbeiter.

GeneralSome questions about the control Pinmembergreg_quinn13-Jun-11 0:55 
GeneralRe: Some questions about the control PinsitebuilderUwe Keim13-Jun-11 18:58 
GeneralRe: Some questions about the control Pinmembergreg_quinn15-Jun-11 2:59 
GeneralRe: Some questions about the control PinsitebuilderUwe Keim18-Jun-11 3:02 
GeneralRe: Some questions about the control Pinmembergreg_quinn15-Jun-11 3:13 
QuestionHow to insert an image? Pinmemberseanzcan7-Jun-11 3:53 
GeneralGo Zeta Go Pinmembersam.hill2-Jun-11 10:27 
GeneralRe: Go Zeta Go PinsitebuilderUwe Keim2-Jun-11 18:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 9 Jul 2013
Article Copyright 2009 by Uwe Keim
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid