Windows Forms: How to create a Web Browser in C#
By FoxLearn 7/11/2017 8:06:07 PM 6.22K
How to create a web browser in c#
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "AppWebBrowser" and then click OK
Step 2: Design your form as below
Step 3: Add code to handle your form as below
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace AppWebBrowser { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void txtUrl_KeyPress(object sender, KeyPressEventArgs e) { //Enter key if (e.KeyChar == (char)13) webBrowser.Navigate(txtUrl.Text); } private void btnBack_Click(object sender, EventArgs e) { webBrowser.GoBack(); } private void btnForward_Click(object sender, EventArgs e) { webBrowser.GoForward(); } private void btnRefresh_Click(object sender, EventArgs e) { webBrowser.Refresh(); } private void btnGo_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUrl.Text)) webBrowser.Navigate(txtUrl.Text); } } }
VIDEO TUTORIALS
Categories
Popular Posts
How to Download Chromedriver for Selenium
08/29/2024
C# Tutorial
07/20/2024
How to Download Microsoft SQL Server
06/22/2024
What is ARM architecture?
04/01/2024