开发者

C#, WinForms: Which view type for periodically updated list?

I'm having an application, that periodically polls a web service (about every 10 seconds). In my application logic I'm having a List<Message> holding the messages. All messages have an id, and might be received out of order. Therefore the class implements the Comparable Interface.

What WinForm control would fit to be regurarly updated (with the item开发者_如何学运维s in order). I plan to hold the last 500 messages. Should I sort the list and then update the whole form? Or is data binding approriate (concerning performance)?


If you are working with WinForms, I shall recommend a ListView-control with View-property set to Details along with a BackgroundWorker-control.


If the list is going to be changing each time, and your order is not coming in consistently, I'd just sort your list and reupdate the entire UI.

You should be able to do the list fetching + sorting in a background thread, so the main "UI" blocking will just be redrawing the UI. With 500 elements, this won't be fast, but it should be tolerable.


i'd use databinding with the BindingList in System.ComponentModel wrapping your List.

BindingList in this case, would allow you to update your List object with new data and will automatically re-bind your data to the control that you are using for display.

which control you use would depend on how you want it to look. any control that supports databinding to a collection would work, though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜