ARTICLE

Webrowser control in WPF using VB.NET

Posted by Rohatash Kumar Articles | WPF using VB.NET January 24, 2011
In this article we will learn how to use WebBrowser control in WPF using VB.NET.
 
Reader Level:

In this article we will learn how to use WebBrowser control in WPF using VB.NET.

WebBrowser control

we can use WebBrowser control to show html document within our WPF application.

XAML code

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="MainWindow" Height="350" Width="525">

    <Grid Height="431" Width="611">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="231*" />

            <ColumnDefinition Width="272*" />

        </Grid.ColumnDefinitions>

        <WebBrowser Height="248" HorizontalAlignment="Left" Name="WebBrowser1" VerticalAlignment="Top" Width="503" Margin="0,12,0,0" Grid.ColumnSpan="2" />

        <Button Content="Forward" Height="23" HorizontalAlignment="Left" Margin="190,276,0,0" Name="Button1" VerticalAlignment="Top" Width="75" Grid.ColumnSpan="2" />

    </Grid>

</Window>

 

The form looks like this.

bw1.gif

figure 1.

Navigate method on WebBrowser control is used to load the site in the control.

Now double click on the forward Button it will navigate to http://www.c-sharpcorner.com.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click

        WebBrowser1.Navigate(New Uri("http://www.c-sharpcorner.com"))

    End Sub

 

    Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded

        WebBrowser1.Navigate(New Uri("http://www.google.com"))

    End Sub

 

Now run the application and test it. I have made google.com as default web site to be loaded.


bw2.gif 


Figure 2.

 

Now click on the Button forward.


bw3.gif 

Figure 3.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor