如何在进度栏上显示刻度线?

发布于 2024-07-10 08:56:04 字数 155 浏览 8 评论 0原文

我正在下载一组文件,并且想在进度栏中显示进度。 通过将进度条的最大值设置为所有文件的总大小,并将当前位置设置为到目前为止下载的大小,可以简单地显示总体进度。

我想做的是将进度条分成几个部分,每个部分代表集合中的不同文件。

这可能吗? 我该怎么做呢?

I'm downloading a collection of files, and I'd like to display progress in a progress bar. It's simple to display overall progress by setting the maximum value of the progress bar to the total size of all the files, and by setting the current position to the size downloaded so far.

What I'd like to do is separate the progress bar into segments, with each section representing a different file in the collection.

Is this possible? How would I do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

儭儭莪哋寶赑 2024-07-17 08:56:04

我认为最简单的方法是创建一个 UserControl,在其上放置一个 ProgressBar,覆盖 UserControl 的 OnPaint() 并绘制线条。

我认为 UserControl 比直接在窗体上绘图更容易处理。 坐标会更容易处理,而且在其他应用程序中重用它也会更容易。

I think the easiest way would be to make a UserControl, drop a ProgressBar on it, override the UserControl's OnPaint() and draw your lines.

I think a UserControl would be a little easier to deal with than drawing right on the form. The coordinates would be easier to handle plus it'd be easier to reuse it in another application.

海风掠过北极光 2024-07-17 08:56:04

如果您知道要下载的文件的总大小,并且知道到目前为止下载的文件的总大小,那么您可以将 .Maximum 设置为文件的总大小,将 .Position 设置为到目前为止下载的总大小。 无需担心文件大小如何分配。

或者您的意思是您希望根据每个文件的大小在进度条上标记刻度线?

If you know the total size of the files to be downloaded, and you know the total size of the files downloaded so far, then you can just set .Maximum to the total size of the files, and .Position to the total downloaded so far. No need to worry about how the size is split between the files.

Or did you mean that you want tick marks on the progress bar according to the size of each file?

—━☆沉默づ 2024-07-17 08:56:04

将最大值设置为 100。然后,对于下载的每个文件,执行 100*(file_size/total_download_size) 并将它们加在一起。 将它们的值加在一起后,设置进度条的值。 每次文件下载完成时更新该值。

Set the max value to 100. Then for each file that is downloaded do 100*(file_size/total_download_size) and add them together. Once you have the value of them added together, set the progress bar's value. Update the value each time a file finishes downloading.

只有一腔孤勇 2024-07-17 08:56:04

您可以使用两个进度条,一个用于每个文件,一个用于总计。 或者,如果您想要刻度线:简单的解决方案是在该栏下方或上方添加一些线条。

You can use two progress bars one for each file and one for total. Or if you want tick marks: Simple solution is to add some lines under or above that bar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文