StrataFrame Forum

Error double click form caption with StrataListView

http://forum.strataframe.net/Topic28914.aspx

By Edhy Rijo - 11/8/2010

On some situation, when a form with StrataListView is double clicked on the form's caption to maximize it, an exception will be trigger by the StartaListViewItemCollection.Sort() method.

Any ideas on how this could be trapped? also, any news on upcoming updates for the StrataListView?

Here is the exception:

InvalidOperationException
  Failed to compare two elements in the array.
ArgumentOutOfRangeException
  Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Source     : mscorlib

Stack Trace:
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at MicroFour.StrataFrame.UI.Rendering.Sorting.StrataListViewSorter.System.Collections.IComparer.Compare(Object x, Object y)
   at System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)
   at System.Array.SorterObjectArray.QuickSort(Int32 left, Int32 right)
   at System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer)
   at System.Collections.ArrayList.Sort(Int32 index, Int32 count, IComparer comparer)
   at System.Collections.ArrayList.Sort(IComparer comparer)
   at MicroFour.StrataFrame.UI.Collections.StrataListViewItemCollection.Sort()
   at MicroFour.StrataFrame.UI.Windows.Forms.StrataListView.ManageMouseUp_Columns(MouseEventArgs e)
   at MicroFour.StrataFrame.UI.Windows.Forms.StrataListView.ManageMouseUp(MouseEventArgs e)
   at MicroFour.StrataFrame.UI.Windows.Forms.StrataListView.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
   at System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at MicroFour.StrataFrame.Application.StrataFrameApplication.RunApplication()


Thanks!
By Greg McGuffey - 11/9/2010

What situations does this occur?
By Edhy Rijo - 11/9/2010

Hi Greg,

Based on the stack it is coming from " MicroFour.StrataFrame.UI.Collections.StrataListViewItemCollection.Sort()" method. 

I have a checkbox in the first column of my listview and in my subclass I handle the OnDoubleClick to automatically check/uncheck this checkbox, also when clicking the 1st column header, I have code to check/uncheck all items, but as I reported before, this may be fighting with the sorting which cannot be disabled yet.

I catch this on a form when double clicking the form's caption to maximize it.  I need to put more time (which I don't have Crazy) to try to duplicate this more clearly.
By Greg McGuffey - 11/9/2010

My guess is that when you double click the form, thus maximizing it, this in turn ends up re-rendering the listview, which needs to do a sort. Then something is breaking. Not sure I can of much more help without a sample app though.