Hi All,
I am using Ultralistview in my forms and i have set one of its columns in sorting mode. I am dynamically updating/adding items in it based on the data from a server. Whenver i add an item in the ultralistview, it places the item according to the sort order dynamically. Can i disable this option of dynamic sort, so that only when the user refreshes/tries to change the sort order, items will be sorted?
Thanks in Advance,
Manikandan
Ok Brian.Thanks for the reply. Now i am able to get some picture.
I will log it as a bug.
And will try to do some investigation and testing on the same.
Thanks and Regards
I was able to reproduce the issue you described here. When a column needs to be sorted, we call the Sort method off the ArrayList class, passing in our internal IComparer implementation (when the SortComparer property is not explicitly set), which in this scenario always returns zero, since the item values for the column being sorted are identical. Regardless of the fact that the IComparer implementation returns zero for every single item, the ArrayList class is reordering them. Incidentally, this would seem to contradict the MS documentation on the subject (see http://msdn2.microsoft.com/en-us/library/0e743hdt.aspx):
"If comparer is set to null (Nothing in VB), then this method performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. To perform a stable sort you must implement a custom IComparer."
You should report this as a bug; we currently use the QuickSort algorithm since there was previously no reason not to, but I suppose this could be changed to use a binary sort instead, which performs a stable sort.
Regarding the BeginUpdate/EndUpdate methods: there is no correlation between these methods and the number of items being sorted; the BeginUpdate method simply suspends painting operations until the EndUpdate method is called. We do recommend that you wrap the calls in a try/finally so that the the EndUpdate method is guaranteed to be called, since not closing a call to BeginUpdate with an EndUpdate will cause painting to be suspend indefinitely, which obviously can disorient the end user.
Hi Brian,
Thanks for the reply and sorry for the late reply from my side. I was stuck with something else.The issue i was mentioning is reproducable from my side. The issue may not be exactly in the classical sense of 'Flickering'. But i am able to reproduce the thing in a sample application. I created a listview with five columns and seven rows to have some sample data of students. Out of the five columns, two columns(Daparment and Age) can have same values across all the seven rows. When i sort this list view with respect to any one of these two columns (Department and Age) and then updating the value of some other column across all the rows in a loop. What i happened to see is all the rows are re-ordering whenever the value is changed in some other column. since my sorted column has identical values across all the rows at any point of time, i wouldn't expect this re-ordering to happen.
Can you put some light on what exactly is happening is this case?
However this issue doesn't happen when as per your suggestion i do BeginUpdate and EndUpdate before and after updating the data respectively.
Is it Ok to use this BeginUpdate and EndUpdate for updating huge number of rows like 15,000 rows, which has a chance of getting updated every second.
Thanks in Advance
Any updates on this?