Free C# Tutorials

home
Stay at Home and Learn

Build your own C# Custom Web Browser

 
Computer Tutorials List

 

 

 

 

To end this section on Events, we'll show you how to build your own custom browser in C# .NET. We'll only use three control: a SplitContainer, A TreeView and, of course, a WebBrowser control. It's surprisingly easy!

Start a new project for this. Select your form and make it nice and big. Expand the Toolbox and locate the SplitContainer. A SplitContainer allows you to have one control in one half and another control in the other half. We'll put the TreeView control on the left, and the browser on the right. But the SplitContainer looks like this:

The C# SplitContainer Control

Double click to add a SplitContainer to your form. By default, it will fill the whole form, and anchor itself to the top left corner. To change this, locate the Anchor property of the SplitContainer. Click the down arrow to see the following:

The Anchor property of the SplitContainer

Top, Left is indicated by the grey squares. Click the two smaller white rectangles and they'll go grey as well:

Anchor the SplitContainer Top, Left, Bottom and Right

The SplitContainer on your form should then look something like this:

The SplitContainer with two Panels

As you can see, it has a Panel1 and a Panel2. We'll put a TreeView control in Panel1 and WebBrowser control in Panel2. (One thing to note about the SplitContainer, though, is that it's incredibly fiddly if you want to select just the SplitContainer itself, rather than one of the Panels. If you click in the thin area between the two panels it will select the whole container.)

Just before we get on to the TreeView control, locate the BorderStyle property of the SplitContainer and change it to either Fixed Single or Fixed 3D. If you Run your form now, it should look like this (Fixed 3D):

Fixed 3D SplitContainer

The two panels can be resized. Move your mouse to thin strip in the middle and the pointer will change shape. Hold down your left mouse button and you can drag to resize.

 

<-- ListBox and ComboBox Events | The Tree View Control in C# -->

<--Back to the C# .NET Contents Page

View all our Home Study Computer Courses