C# - 多个进度条列表。使用什么组件?
我有一个应用程序,需要将多个进度条动态添加到表单中(每当添加并开始新的上传时)。
我一直在谷歌搜索,结果建议在 ListView 或 DataGridView 中嵌入进度条。
任何人都可以建议任何其他技术,因为到目前为止我所看到的 ListView 或 DataGridView 黑客似乎都没有吸引力?
I have an app that requires multiple progress bars to be added dynamically to a form (whenever a new upload is added and started).
I've been Googling and the results suggested embedding progress bars in a ListView or a DataGridView.
Can anyone suggest any other techniques, as neither ListView or DataGridView hacks I've seen so far seem appealing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我建议创建一个自定义控件,也许使用面板作为基本控件。添加进度条、文件名、其他文件信息等控件,并将所有内容公开为属性。编写函数,以便它们自动处理自己的进度。
通过这种方式,您可以像其他任何东西一样实例化它们,并将它们添加到滚动区域,而不必过多担心每个属性。这只是帮助您入门的基本想法。如果这还不够清楚,请告诉我。
以下是创建自定义控件的一个相对完整的示例: http://www.akadia.com/services/ dotnet_user_controls.html
I would recommend creating a custom control, perhaps using a Panel as a base control. Add the controls for the progress bar, file name, other file information, etc.. and expose everything as properties. Write the functions so that they automatically handle their own progress.
This way you can instantiate them like anything else, and add them to a scrolling area, without having to worry too much about the properties of each. This is just a base idea to get you started. Let me know if this isn't clear enough.
Here's one relatively thorough example of creating a custom control: http://www.akadia.com/services/dotnet_user_controls.html
我猜是
TableLayoutPanel
会更容易。为每个
ProgressBar
添加一列并添加一行。或者两列,一列带有
Label
,一列带有ProgressBar
。I guess a
TableLayoutPanel
would be easier.One column and add a row for each
ProgressBar
.Or two columns, one with a
Label
and one with theProgressBar
.我个人对它们了解不多,但我认为如果您使用后台工作人员,他们可能会提供帮助,因为您可以调用一个方法来通知程序已取得进展,并且您可以更新进度栏。< a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx" rel="nofollow" title="后台工作人员">后台工作人员
I personally don't know much about them myself but I think if you used Background workers they mgiht be able to help as you can call a method that notifies the program that progress has been made and with that you can update the progress bar.Background worker
如果允许使用第三方控件,我建议使用类似 XtraGrid< /a> 来自 DevEx。这很容易实现,你会觉得自己在作弊。
If using third party controls is allowed, I would suggest something like XtraGrid from DevEx. It will be so easy to pull off you'll feel you are cheating.
另一种方法是使用
OwnerDraw
属性为 true 的ListView
并响应DrawSubItem()
事件。使用已提供的e.Graphics
对象在事件参数中给出的给定矩形e.Bounds
内绘制进度条非常简单。这是一个例子
An alternative is to use a
ListView
withOwnerDraw
property true and respond to theDrawSubItem()
event. Drawing a progress bar is supereasy within the given rectanglee.Bounds
that is given in the event arguments using the already suppliede.Graphics
object.Here is an example