当前位置:编程学习 > asp >>

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);
            }
        }

      
    }
 

 


摘自 loafinweb

补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,