WEBSITE

Embed a Web Browser in Your Application

9/26/2010 7:46:47 PM
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.

Figure 1. It is quite simple to create your own web browser by using the existing functionality from Internet Explorer.


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.

Other  
 
Most View
The next Nexus (Part 2)
How To Buy…Network Attached Storage (Part 1)
JBL Flip - A Small Device Making A Big Impression
Asus F2A55-M - A Good-Value FM2 Board
Guide To Upgrades With The Greatest Effects (Part 1)
Sharepoint 2010 : Designing Workflows with Visio 2010 (part 1) - Designing a Visio Workflow
What To Do With An Old Mac (Part 1)
Work Zone On Smartphone (Part 1)
Sony Xperia Z Review (Part 3)
Arbico Elite 7768 OCX - Great-Value Gaming Rig
Top 10
Sharepoint 2013 : Farm Management - Disable a Timer Job,Start a Timer Job, Set the Schedule for a Timer Job
Sharepoint 2013 : Farm Management - Display Available Timer Jobs on the Farm, Get a Specific Timer Job, Enable a Timer Job
Sharepoint 2013 : Farm Management - Review Workflow Configuration Settings,Modify Workflow Configuration Settings
Sharepoint 2013 : Farm Management - Review SharePoint Designer Settings, Configure SharePoint Designer Settings
Sharepoint 2013 : Farm Management - Remove a Managed Path, Merge Log Files, End the Current Log File
SQL Server 2012 : Policy Based Management - Evaluating Policies
SQL Server 2012 : Defining Policies (part 3) - Creating Policies
SQL Server 2012 : Defining Policies (part 2) - Conditions
SQL Server 2012 : Defining Policies (part 1) - Management Facets
Microsoft Exchange Server 2010 : Configuring Anti-Spam and Message Filtering Options (part 4) - Preventing Internal Servers from Being Filtered