Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
UltraListView.Clear(0 Throws null reference exception on version 17.2
posted

After upgrading to version 17.2, if i call .Clear in  either the items, or in  selected items for an ultralistview using the Details view.

It throws a null exception.

Prior to upgrading to version 17.2, everything was working fine with  no changes on code on my side.


I removed all events and went to a simple implementation, and  still doing it.
I am also using  suspend layout

What i believe is that on your .Clear method, you  are stepping through the  items in reverse order and  removing them one at a time.
However, you are keeping a reference on each item, to see if it needs to  be disposed (or something).
Even if  item is not disposed, some kind of internal  event is raised by the  collection that when handled throws an error in  the referenced event

For a simple clear of items in collection, this  is easy to  bypass by writing by own  Clear routine.

However, for moving items to different positions in the list using the  selected items, i have to keep a reference to the selected item.
Thus  when  i remove the item being moved, it raised an  event handled by the reference to the selected item, and throws an  error.

There is not way i can avoid this,  short of copying the data out of the  item being removed from collection before removing it, then  recreating the item from scratch. (this is a pain  as would have to  go  through  a large application with many  views).


One  more  thing, if i handle the property change event, and display  each property change in a dialog, the null  reference exception is not thrown,  i am guessing because enough time is given. This looks like there is some kind of  async process used internally by utltra list view.

I hope this gets high priority


  • 18204
    Offline posted

    Hello Michael,

    Thank you for posting in our forums!

    I tried to reproduce this behavior with the information you provided and was unable to reproduce any exceptions when Clearing either the Items or SelectedItems collections.

    The best way for us to assist you is if you provide a small, isolated sample that we can run and use for debugging locally.

    If you are unable able to provide an isolated sample I may be able to give suggestions if you provide the code for your page.


    Sincerely,
    Michael H.
    Software Developer
    Infragistics, Inc.
    www.infragistics.com/support