WebBrowser 加 上进度条
源文件View Code
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 WindowsFormsApplication1
{
public partial class WebBrowserProgressBar : Form
{
public WebBrowserProgressBar()
{
InitializeComponent();
}
//初始from
private void WebBrowserProgressBar_Load(object sender, EventArgs e)
{
progressBar1.Visible = false;
}
//加载进度条
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
progressBar1.Visible = true;
if ((e.CurrentProgress > 0) && (e.MaximumProgress > 0))
{
progressBar1.Maximum = Convert.ToInt32(e.MaximumProgress);
progressBar1.Step = Convert.ToInt32(e.CurrentProgress);
progressBar1.PerformStep();
}
else if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
progressBar1.Value = 0;
progressBar1.Visible = false;
}
}
//跳转
private void btnGo_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBox1.Text))
{
webBrowser1.Navigate(textBox1.Text);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class WebBrowserProgressBar : Form
{
public WebBrowserProgressBar()
{
InitializeComponent();
}
//初始from
private void WebBrowserProgressBar_Load(object sender, EventArgs e)
{
progressBar1.Visible = false;
}
//加载进度条
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
progressBar1.Visible = true;
if ((e.CurrentProgress > 0) && (e.MaximumProgress > 0))
{
progressBar1.Maximum = Convert.ToInt32(e.MaximumProgress);
progressBar1.Step = Convert.ToInt32(e.CurrentProgress);
progressBar1.PerformStep();
}
else if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
progressBar1.Value = 0;
progressBar1.Visible = false;
}
}
//跳转
private void btnGo_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(textBox1.Text))
{
webBrowser1.Navigate(textBox1.Text);
}
}
}
个人签名:天行健,君子以自强不息