The following sample code demonstrates how to create WinForms Browser instance, embed it into a Form and load http://www.google.com URL. More details about configuring the sample can be found in the Quick Start Guide.


The sample solution that demonstrates how to embed lightweight or heavyweight controls into Windows Forms can be found in the attachments. The projects in this solution have NuGet dependencies, which will be resolved automatically during the build.




Adding DotNetBrowser to the Toolbox


If you want to add the DotNetBrowser controls to the Visual Studio Toolbox, the most convenient way is to download and install the VSIX package that is available at Visual Studio gallery.


Embedding from the Code

C# 

Form1.cs

using System.Windows.Forms;
using DotNetBrowser;
using DotNetBrowser.WinForms;

namespace WinForms.DotNetBrowser
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            BrowserView browserView = new WinFormsBrowserView();
            Controls.Add((Control) browserView);
            browserView.Browser.LoadURL("http://www.google.com");
        }
    }
}


VB.NET

Form1.vb

Imports DotNetBrowser
Imports DotNetBrowser.WinForms

Public Class Form1

    Public Sub New()

        Dim browserView As BrowserView
        InitializeComponent()

        browserView = New WinFormsBrowserView()
        Controls.Add(browserView)
        browserView.Browser.LoadURL("http://www.google.com")
    End Sub
End Class