You
can use the Internet Explorer component included with .NET. In Visual
Studio, it shows up under Common Controls in the Form Designer.
You can use the WebBrowser control just like you would any other control and arrange it how you want. Figure 1 shows an example of a simple browser.
Listing 1 provides a snippet of the code that manipulates the browser control.
Listing 1. Custom Web Browser
using System; using System.ComponentModel; using System.Windows.Forms;
namespace WebBrowser { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void buttonGo_Click(object sender, EventArgs e) { if (radioButtonUrl.Checked) { this.webBrowser1.Navigate(textBoxUrl.Text); } else { this.webBrowser1.DocumentText = textBoxHTML.Text; } }
private void OnRadioCheckedChanged(object sender, EventArgs e) { textBoxUrl.Enabled = radioButtonUrl.Checked; textBoxHTML.Enabled = radioButtonHTML.Checked; } } }
|
As
you can see, it’s equally easy to show your own content or anything on
the Web. However, the renderer is always Internet Explorer, regardless
of what you put around it (just right-click on a page to see the
standard IE context menu). Keep this in mind when dealing with
JavaScript, for example.