Design a web browser in C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BrowserExample
{
public partial class Form1 : Form
{
public Form1({
InitializeComponent();
}
private void
txt_Url_KeyPress(object sender, KeyPressEventArgs e){
if (e.KeyChar == (char)13)
{
webBrowser1.Navigate(txt_Url.Text);
}
}
private void
Form1_Load(object sender, EventArgs e){
btn_Stop.Enabled = false;
btn_fwd.Enabled = false;
btn_backwrd.Enabled = false;
}
private void
webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e){
txt_Url.Text = webBrowser1.Url.ToString();
this.Text = webBrowser1.DocumentTitle.ToString();
}
private void
webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e){
btn_Stop.Enabled = true;
}
private void
webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e){
btn_Stop.Enabled = false;
if
(webBrowser1.CanGoBack){
btn_fwd.Enabled = true;}
else{
btn_fwd.Enabled = false;}
if (webBrowser1.CanGoBack){
btn_fwd.Enabled = true;}
else{
btn_fwd.Enabled = false;
}
}
private void
btn_Home_Click_1(object sender, EventArgs e){
webBrowser1.GoHome();
webBrowser1.Text = webBrowser1.Url.ToString();
}
private void btn_backwrd_Click_1(object sender, EventArgs
e){
webBrowser1.GoBack();
txt_Url.Text = webBrowser1.Url.ToString();
}
private void
btn_fwd_Click_1(object sender, EventArgs e){
webBrowser1.GoForward();
txt_Url.Text = webBrowser1.Url.ToString();
}
private void
btn_Stop_Click_1(object sender, EventArgs e){
webBrowser1.Stop();
}
private void
btn_Refresh_Click_1(object sender, EventArgs e){
webBrowser1.Refresh();
}
private void
btn_GO_Click_1(object sender, EventArgs e){
webBrowser1.Navigate(txt_Url.Text);
}
private void
btn_Favourite_Click(object sender, EventArgs e){
}
}
}
No comments:
Post a Comment