ultralistview:Items:Clear() raises error

Posted by Darren Parr on 04-Aug-2016 08:51

Hi

I dont seem to be able to get around this one. Im using an ultralistview in 11.6.2 and am able to populate it nicely. As soon as I attempt to clear the items collection I get the following error.

Any ideas? The stack trace just points to the clear() method. This should just work.

Posted by Darren Parr on 04-Aug-2016 17:35

Ive largely solved this. It was down to a c# hook (we use dll's for some iterative work) which was erroring in itemclick. The clear was raising an itemclick which was in correctly checking selecteditems[0] which didn't exist. No trace of it in the stack trace but it was there.

Everyone thanks for your help.

All Replies

Posted by Laura Stern on 04-Aug-2016 08:57

I assume you are just calling the Clear() method?  Or are you removing the items one by one?  Remember that .NET indexes are 0-based.  

Posted by Darren Parr on 04-Aug-2016 09:01

I'm just using the clear() method.. If I step through the collection, removing them one by one, it crashes as soon as I lose the last one with the same error. I've tried all sorts to get this working. I even wrote a c# dll to do the clear() method and it did the same.

Interestingly enough you get the same error when calling SelectedItems:Clear() before doing the items:Clear().

Posted by Darren Parr on 04-Aug-2016 09:30

The .net stack trace says..

.NET StackTrace:

-->   at System.Collections.ArrayList.get_Item(Int32 index)

  at Infragistics.Win.UltraWinListView.UltraListViewStateSpecificItemsCollectionBase.get_Item(Int32 index)

I don't think this is much help.

Posted by Laura Stern on 04-Aug-2016 09:55

* Seems like a bug, doesn't it?  Though, it's such a basic thing, that seems surprising.

* For debugging, did you just walk thru the items from 0 to Count -1 and get the value?  Can you do that successfully?  This would prove that the Count is or is not messed up somehow.

* Can you show the code that you used to remove the items one by one.  

* Interesting that the stack shows they are at get_item().  I wonder why would they be getting the item in order to get rid of it.  We have the Infragistics source code here.  I'd have to go find it.  I could look at what they're doing.  So what is the exact class that you are calling Clear() on?

Posted by Darren Parr on 04-Aug-2016 10:02

The class is Infragistics.Win.UltraWinListView.UltraListView

My code is as follows..

THIS-OBJECT:ListView:Items:Clear().

To step through I did the following..

DO iCount = THIS-OBJECT:ListView:Items:Count To 1 BY -1

 THIS-OBJECT:ListView:Items:RemoveAt(iCount - 1).

END.

Posted by Brian K. Maher on 04-Aug-2016 10:04

THIS-OBJECT:ListView:Items:RemoveAt(0).
 

Posted by Darren Parr on 04-Aug-2016 10:05

To debug it and have a look at the state of the control I used the following command..

WAIT-FOR (NEW Infragistics.Shared.UltraPropertyPageDialog(THIS-OBJECT:ListView)):ShowDialog().

Posted by Laura Stern on 04-Aug-2016 10:20

Not sure - but I think Brian is saying you can do this:

iCount = THIS-OBJECT:ListView:Items:Count.

DO idx = 0 TO iCount -1:

 THIS-OBJECT:ListView:Items:RemoveAt(0).

END.

Posted by Darren Parr on 04-Aug-2016 11:17

That works too or simply a repeat loop while the count > 0 with a removat(0). I'm afraid to say the results are the same. It doesnt like the clear().

Posted by Laura Stern on 04-Aug-2016 11:52

Looked at the Infragistics code in the Items collection Clear() method.  It is basically this.  The first line in the loop would be the thing calling get_item().  This looks OK to me.

int count = this.Count;

for ( int i = count - 1; i >= 0; i-- )

{

      UltraListViewItem item = this[i];

       this.RemoveHelper(i, false);

       if ( dispose )

            item.Dispose();        

}

Posted by Darren Parr on 04-Aug-2016 17:35

Ive largely solved this. It was down to a c# hook (we use dll's for some iterative work) which was erroring in itemclick. The clear was raising an itemclick which was in correctly checking selecteditems[0] which didn't exist. No trace of it in the stack trace but it was there.

Everyone thanks for your help.

This thread is closed