欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

WebBrowser加上进度条

程序员文章站 2022-03-13 17:46:30
源文件 view code     using system; using system.collections.generic; u...
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