C#中的webBrowser控件加载网页时实现进度显示
代码
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 Form1_Load(object sender, EventArgs e)
{
Uri strurl = new Uri("http://www.hainan.com");
webBrowser1.Url = strurl;
webBrowser1.ProgressChanged += new WebBrowserProgressChangedEventHandler(webBrowser1_ProgressChanged);
}
{
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 Form1_Load(object sender, EventArgs e)
{
Uri strurl = new Uri("http://www.hainan.com");
webBrowser1.Url = strurl;
webBrowser1.ProgressChanged += new WebBrowserProgressChangedEventHandler(webBrowser1_ProgressChanged);
}
VB.Net 中的webBrowser控件加载网页时实现进度显示
代码
Private Sub WebBrowser1_ProgressChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
ToolStripProgressBar1.Visible = True
If (e.CurrentProgress > 0) And (e.MaximumProgress > 0) Then
ToolStripProgressBar1.Maximum = Convert.ToInt32(e.MaximumProgress) '设置正在加载的文档总字节数
ToolStripProgressBar1.Step = Convert.ToInt32(e.CurrentProgress) '//获取已下载文档的字节数
ToolStripProgressBar1.PerformStep()
ElseIf WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
ToolStripProgressBar1.Value = 0
ToolStripProgressBar1.Visible = False
End If
End Sub
ToolStripProgressBar1.Visible = True
If (e.CurrentProgress > 0) And (e.MaximumProgress > 0) Then
ToolStripProgressBar1.Maximum = Convert.ToInt32(e.MaximumProgress) '设置正在加载的文档总字节数
ToolStripProgressBar1.Step = Convert.ToInt32(e.CurrentProgress) '//获取已下载文档的字节数
ToolStripProgressBar1.PerformStep()
ElseIf WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
ToolStripProgressBar1.Value = 0
ToolStripProgressBar1.Visible = False
End If
End Sub
StatusStrip如何添加分割栏? ?
应该VS2005这个方面做的“漏掉了”这个功能,
可以手动来改一下代码,把它的其中一个Itme改成这个分隔条就可以了。比如:
private System.Windows.Forms.ToolStripStatusLabel toolSeparator1;
相应的改为:
private System.Windows.Forms.ToolStripSeparator toolSeparator1;
就是说这个分隔条还是ToolStripSeparator。
这个修改可以在窗体的Form1.Designer.cs文件里直接改,改好后确认无误了再切换到设置界面就可以出现分隔条“|”了。