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.
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.
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().
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.
* 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?
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.
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().
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.
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().
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();
}
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.