Windows 窗体 ProgressBar:启动/停止选取框的最简单方法? [英] Windows Forms ProgressBar: Easiest way to start/stop marquee?
问题描述
我正在使用 C# 和 Windows 窗体.我有一个正常的进度条在程序中工作正常,但现在我有另一个操作,无法轻松计算持续时间.我想显示一个进度条,但不知道启动/停止滚动字幕的最佳方式.我希望有一些简单的事情,比如设置跑马灯速度,然后有一个 start() 和 stop(),但它似乎并不那么简单.我必须在后台运行一个空循环吗?我如何最好地做到这一点?谢谢
I am using C# and Windows Forms. I have a normal progress bar working fine in the program, but now I have another operation where the duration cannot be easily calculated. I would like to display a progress bar but don't know the best way to start/stop the scrolling marquee. I was hoping for something as simple as setting the marquee speed and then having a start() and stop() but it doesn't appear to be that simple. Do I have to run an empty loop in the background? How do I best do this? Thanks
推荐答案
使用样式设置为 Marquee
的进度条.这表示一个不确定的进度条.
Use a progress bar with the style set to Marquee
. This represents an indeterminate progress bar.
myProgressBar.Style = ProgressBarStyle.Marquee;
您还可以使用 MarqueeAnimationSpeed
属性用于设置小块颜色在进度条上设置动画所需的时间.
You can also use the MarqueeAnimationSpeed
property to set how long it will take the little block of color to animate across your progress bar.
这篇关于Windows 窗体 ProgressBar:启动/停止选取框的最简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!