Click here to Skip to main content
6,933,325 members and growing! (12,234 online)
Email Password   helpLost your password?
 
Desktop Development » Edit Controls » General     Beginner License: The Code Project Open License (CPOL)

Zeta HTML Edit Control

By Uwe Keim

A small wrapper class around the Windows Forms 2.0 WebBrowser control
C#, .NET (.NET2.0), WinForms, Dev
Revision:6 (See All)
Posted:17 Nov 2009
Updated:18 Nov 2009
Views:5,382
Bookmarked:44 times
printPrint Friendly   add Share
      Discuss Discuss   Broken Article?Report  
17 votes for this article.
Popularity: 5.89 Rating: 4.78 out of 5

1

2
1 vote, 5.9%
3
2 votes, 11.8%
4
14 votes, 82.4%
5

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) applications.

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
  • Provide an alternative context menu for applying formatting options
  • Optionally directly edit the underlying HTML source code
  • Translate 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

  • 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)

About the Author

Uwe Keim


Member
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 is also teached programming to students at the local university.

In his free time, he does climbing, running and mountain biking. You can watch him most of the day (and probably night) programming.

Some cool, free software from us:

Zeta Test - Integrated test management environment.
Zeta Producer - Intuitive Content Management System (CMS) for Windows.
Zeta Uploader - Easily send large files by e-mail.

Occupation: Software Developer
Company: zeta software GmbH
Location: Germany Germany

Other popular Edit Controls articles:

 
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 9 of 9 (Total in Forum: 9) (Refresh)FirstPrevNext
GeneralFirst of all 5 from me Pinmembermheidari2:21 24 Nov '09  
GeneralRe: First of all 5 from me PinsitebuilderUwe Keim3:47 24 Nov '09  
GeneralRe: First of all 5 from me Pinmembermheidari23:14 24 Nov '09  
General5 Sterne / 5 Stars PinmemberMidnight Run6:43 19 Nov '09  
GeneralRe: 5 Sterne / 5 Stars PinsitebuilderUwe Keim6:49 19 Nov '09  
GeneralRe: 5 Sterne / 5 Stars PinmemberMidnight Run6:55 19 Nov '09  
General"Control" Project does not compile - Missing File? Pinmemberandre123453:12 18 Nov '09  
GeneralRe: "Control" Project does not compile - Missing File? PinsitebuilderUwe Keim4:11 18 Nov '09  
GeneralRe: "Control" Project does not compile - Missing File? Pinmemberandre123451:53 19 Nov '09  
Yes, it done now compile, thank you!

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 18 Nov 2009
Editor: Deeksha Shenoy
Copyright 2009 by Uwe Keim
Everything else Copyright © CodeProject, 1999-2010
Web17 | Advertise on the Code Project