
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Using the New Web Browser Control
|
805
14.9 Using the New Web Browser Control
Problem
You need to display HTML-based content in a WinForms-based application.
Solution
Use the System.Windows.Forms.WebBrowser class to embed web browser functionality
into your application. The Cheapo-Browser seen in Figure 14-1 shows some of the
capabilities of this control.
While this is not a production quality user interface, it is called Cheapo-Browser for
a reason. It can be used to select a web address, display the content, navigate for-
ward and backward, cancel the request, go to the home page, add HTML directly to
the control, print the HTML or save it, and finally enable or disable the context
menu inside of the browser window. The
WebBrowser control is capable of much
more, but this recipe is meant to give you a flavor of what is possible. It would be
well worth exploring its capabilities further to see what other needs it might fill.
Figure 14-1. The web browser control