Add multiple rows simultaneously
HI,
Is it possible to add multiple data objects simultaneously to the a ThreadSafeBindingList. I would like to add a range(list) of objects directly to the grid. Is that possible and if it is, is it there a performance benefit to be gained from adding data objects in batches as opposed to single items. For example adding a list of 50 objects to the ThreadsafeBinding list vs using the Add fuction 50 times.
Thanks,
Deepak
-
Hi,
Yes, you can. All operations in this collection are safe except the iteration. The grid iterates this collection only once when the Grid.DataSource property is called. If you add/remove new data, the grid gets the modified item without iteration.
The ThreadSafeBindingList doesn't have methods to add objects in batches. How many objects you want to add? As an idea to accelerate the process you can firstly populate the collection and then bind it to the grid.
Best regards,
Dapfor
0 -
We have an application that displays trades as they come in. At times there can be several trades which come in the same instant. Existing trades/rows get pushed down when new trades come in. Currently what happens is when a bunch of trades come in, the existing row gets pushed down once for each new trade. We would like to batch update the grid so the existing row only draws once when there is a batch as opposed to once for each new trade. What would be the best method to achieve this. The reason for this conversation was we do some spikes in CPU when we get a burst of new rows added.
Thanks0 -
Hi,
You can use Grid.BeginUpdate() / Grid.EndUpdate() methods to prevent from the vertical scrolling between these calls. In this case the grid will redraw its surface only when the Grid.EndUpdate() method is called.
Best regards,
Dapfor
0
Please sign in to leave a comment.
Comments
3 comments