Conclusion

 

WebBrowser Control Example

To test out the new WebBrowser control, we first need to create a new Windows Forms application. In Microsoft Visual Studio 2005, select New on the File menu, and then select Project. The New Project dialog box appears, as shown in Figure 8-1.

image from book
Figure 8-1: The New Project dialog box in Visual Studio, set to add a new Windows Forms application

In the Project Types list on the left, expand Visual C#, and then select Windows. Select Windows Application from the list of installed templates on the right. Name the project WindowsWebAccess. Click OK, and you will see a screen like the one shown in Figure 8-2.

image from book
Figure 8-2: New Windows Forms application in Design view

From the Common Controls group of the Toolbox, drag and drop a WebBrowser control onto the form. The control is automatically sized to take up the entire form. In the Properties window, you can set properties just as you can for Web Forms controls. One of the properties of the WebBrowser control is the Url property. Set this property to www.microsoft.com/learning/books/. On the Debug menu, select Start Debugging (or press F5) to run the application. Maximize the form, and you will see the Microsoft Press home page, similar to the page shown in Figure 8-3.

image from book
Figure 8-3: Windows Forms application displaying the Microsoft Press home page in a WebBrowser control

With no code, and a single property setting, we have a very simple, serviceable Web browser. If you right-click the WebBrowser control, the menu that appears is the same menu that appears when you right-click a Web page in Internet Explorer, allowing you to go back and forward, view the source of the page, and so on.

 


Programming Microsoft Web Forms
Programming Microsoft Web Forms (Pro Developer)
ISBN: 0735621799
EAN: 2147483647
Year: 2005
Pages: 70
Authors: Douglas J. Reilly
BUY ON AMAZON

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net