C# Windows Forms WebBrowser Examples

Let us look at a simple C# Windows Forms WebBrowser example.

Example 1: WebBrowser

This example will comprise the following files:

  • WebBrowser.cs

Step 1: Create Project

  1. The first step is to create a C# Project.
  2. Go to FILE-->New-->Project to create a new project.

Step 2: Write Code

Write Code as follows:

*(a). WebBrowser.cs

Create a file named WebBrowser.cs

Here is the full code

using System;
using System.Windows.Forms;

namespace Examples {
  class MainForm : Form {
    [STAThread]
    public static void Main() {
      Application.EnableVisualStyles();
      Application.Run(new MainForm());
    }

    public MainForm() {
      Text = "WebBrowser example";
      ClientSize = new System.Drawing.Size(1024, 768);

      webBrowser.Parent = this;
      webBrowser.Dock = DockStyle.Fill;
      webBrowser.Url = new Uri("https://gammasoft71.wixsite.com/gammasoft");
    }

    private WebBrowser webBrowser = new WebBrowser();
  }
}

Run

Simply copy the source code into your C# Project,Build and Run. Alternatively download the code using the links provided below, then open the .csproj project, build and run.

Reference

Download the code using the below links:

Number Link
1. Download Example
2. Follow code author

Related Posts