[Mono-bugs] [Bug 436328] New: Sorting a ComboBox with Custom Items: Invalid Operation Exception
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Thu Oct 16 23:12:48 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=436328
Summary: Sorting a ComboBox with Custom Items: Invalid Operation
Exception
Product: Mono: Class Libraries
Version: 2.0
Platform: Other
OS/Version: Ubuntu
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Windows.Forms
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: lnc19 at hotmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
When sorting a ComboBox i'm getting:
Unhandled Exception: System.InvalidOperationException: The comparer threw an
exception. ---> System.InvalidOperationException: No IComparable or
IComparable<T> interface found for type 'System.Object'.
at System.Array.compare[Object] (System.Object value1, System.Object value2,
IComparer`1 comparer) [0x0008e] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/corlib/System/Array.cs:1727
at System.Array.qsort[Object,Object] (System.Object[] keys, System.Object[]
items, Int32 low0, Int32 high0, IComparer`1 comparer) [0x00025] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/corlib/System/Array.cs:1693
at System.Array.Sort[Object,Object] (System.Object[] keys, System.Object[]
items, Int32 index, Int32 length, IComparer`1 comparer) [0x000df] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/corlib/System/Array.cs:1646
--- End of inner exception stack trace ---
at System.Array.Sort[Object,Object] (System.Object[] keys, System.Object[]
items, Int32 index, Int32 length, IComparer`1 comparer) [0x000f0] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/corlib/System/Array.cs:1649
at System.Array.Sort[Object] (System.Object[] array, Int32 index, Int32
length) [0x00011] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/corlib/System/Array.cs:1580
at System.Collections.ArrayList.Sort () [0x00000] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/corlib/System.Collections/ArrayList.cs:3180
at System.Windows.Forms.ComboBox+ObjectCollection.Sort () [0x00000] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs:2127
at System.Windows.Forms.ComboBox.set_Sorted (Boolean value) [0x00026] in
/home/luciano/mono_opt20/mono-2.0/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs:777
at (wrapper remoting-invoke-with-check)
System.Windows.Forms.ComboBox:set_Sorted (bool)
at TestBugWinForms.TestForm..ctor () [0x00000]
at (wrapper remoting-invoke-with-check) TestBugWinForms.TestForm:.ctor ()
at TestBugWinForms.MainClass.Main () [0x00000]
THE comboBox has items which are "Structs" beacause i need some Custom
Information on each items.
This is working on Microsoft .NET Environment.
The code to reproduce this error:
using System;
using System.Windows.Forms;
namespace TestBugWinForms
{
public class MainClass
{
public static void Main ()
{
Application.Run (new TestForm ());
}
}
}
using System;
using System.Windows.Forms;
namespace TestBugWinForms
{
public struct ComboVal {
public string value;
public string text;
public string MyOtherValue;
public ComboVal (string v, string t, string o)
{
value = v;
text = t;
MyOtherValue = o;
}
// This override is for the Text shown in the ComboBox.
public override string ToString()
{
return text;
}
}
public class TestForm:Form
{
public TestForm()
{
ComboBox cmb = new ComboBox ();
// I add some Structs to the ComboBox (This is valid on
Microsoft Framework, i guess it is the only way to get more than one value on
the ComboBox Item.
cmb.Items.Add (new ComboVal ("1", "Test2", "Other1"));
cmb.Items.Add (new ComboVal ("2", "Test1", "Other2"));
this.Controls.Add (cmb);
cmb.Sorted = true; // Here it is the error.
}
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list