用ProgressBar控件实现Copy文件时进度条的显示,如果在窗体时同时显示百分比呀?
解决方案 »
- 第三方控件DXPerience的一些控件问题1
- 下面的如何用正侧表达式来完成
- 我为asp控件添加了OnClientClick方法,在getinput()中最后调用了confirm,但点取消后程序却照样运行??
- listbox的怪问题,向大家请教.
- DataGrid自动分页后的一个问题。
- AutoCompleteExtender 的问题
- 调用静态方法的问题
- 请教高手,如何用C#给OutLook做插件?
- 关于网络连接状态的编程
- C# winform中如何实现对datagridview中的数据进行预览、打印功能
- 如何实现点击listview中的某一item时,使其产生响应的动作??
- 菜鸟问题:有什么办法可以让TextBox控件只显示文本,不显示边框?
ProgressBar是sealed class!继承不了!上面的方法不可行!嗬嗬
{
// Display the ProgressBar control.
myBar.Visible = true;
// Set Minimum to 1 to represent the first file being copied.
myBar.Minimum = 1;
// Set Maximum to the total number of files to copy.
myBar.Maximum = filenames.Length;
// Set the initial value of the ProgressBar.
myBar.Value = 1;
// Set the Step property to a value of 1 to represent each file being copied.
myBar.Step = 1; //myBar.Style = ProgressBarStyle.Continuous; // Loop through all files to copy.
for (int x = 1; x <= filenames.Length; x++)
{
// Copy the file and increment the ProgressBar if successful.
if (CopyFile(filenames[x - 1],x) == true)
{
// Perform the increment on the ProgressBar.
myBar.PerformStep();
this.label2.Text = Convert.ToString((myBar.Value / Convert.ToDouble(myBar.Maximum)) * 100) + "%";//我在窗体上放了一个Lalbe,调试发现label2.text的值是变了,但是只有当循环执行完了才显示100%
}
}
}
你这种做法,中间Form.Update一下应该没问题.
我觉得想要特殊的外观,自己编一个进度条,没什么难度,完全可以自己做一个,也就是自己处理一下闪屏的问题,现在的双缓存,应该可以解决这个问题,前几年,我看到<四通立方中文平台>的安装进度条,应该是自己用GDI函数绘制的,安装时,闪个没完没了