O'Reilly logo

Visual Basic 2005 Cookbook by Tim Patrick, John Clark Craig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 17. Web Development

Introduction

Programming for the Web is a vast subject worthy of a whole series of books. While we obviously can’t cover everything here, this chapter presents a few web-related recipes for Visual Basic that let you add some useful features to your applications. They will give you some idea of the power of web functionality combined with desktop applications. For a comprehensive collection of Visual Basic web recipes, see ASP.NET 2.0 Cookbook by Michael A. Kittel and Geoff T. LeBlond (O’Reilly).

17.1. Displaying Web Pages on a Form

Problem

You want to display a web page on your form, possibly built from custom HTML content.

Solution

Sample code folder: Chapter 17\CustomWebContent

Sample code folder: Chapter 17\ WebBrowser

Use the WebBrowser control. It encapsulates the core Microsoft Internet Explorer engine, and it integrates easily into your Windows Forms applications.

Discussion

This recipe’s sample code implements a simple web browser. Create a new Windows Forms application, and add the following controls to Form1:

  • A Panel control named WebToolbar. Set its Dock property to Top and its Size.Height property to about 40.

  • A WebBrowser control named WebContent. Set its Dock property to Fill. It should only fill below the Panel control. If it doesn’t, right-click on the Panel control and select “Send to Back” from the shortcut menu.

  • A Button control named ActBack. This control should appear on the surface of the Panel control. Set its Text property to &Back.

  • A Button ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required