Hello mac,
This is from the IComparable Interface entry in the SDK:
This interface is implemented by types whose values can be ordered; for example,
the numeric and string classes.
A value type or class implements the CompareTo method to create a type-specific
comparison method suitable for purposes such as sorting.
This is from the various overloads to Array.Sort in the SDK:
If comparer is a null reference (Nothing in Visual Basic), each element of
array must implement the IComparable interface to be capable of comparisons
with every other element in array.
If the sort is not successfully completed, the results are undefined.
This method uses the QuickSort algorithm. This implementation performs an
unstable sort; that is, if two elements are equal, their order might not
be preserved. In contrast, a stable sort preserves the order of elements
that are equal.
On average, this method is an O(n log n) operation, where n is the Length
of array; in the worst case it is an O(n ^ 2) operation.
Here are some links to the SDK online:
http://msdn2.microsoft.com/en-us/lib...omparable.aspx http://msdn2.microsoft.com/en-us/lib...rray.sort.aspx
Here are some link to various areas on the net
http://www.c-sharpcorner.com/Languag...parablePSD.asp http://www.c-sharpcorner.com/UploadF...4-1991fad8affa
Adam Calderon [C# MVP]
http://blogs.interknowlogy.com/adamcalderon
Hi Adam,
Thanks for the info. I'm pretty new to this, so I don't know what
IComparable is. I will take a look on google. Can you give me a two
sentence preview?
Thanks,
Mac
"Adam Calderon" <http://blogs.interknowlogy.com/adamcalderon/wrote
in message news:1b*************************@msnews.microsoft. com...
>Hello mac,
It might be because your business object being returned from the web
service does not support IComparable. The array does support
Array.Sort
but the underlining object I believe must support IComparable in
order for
things to work. I hope this helps.
Adam Calderon [C# MVP]
http://blogs.interknowlogy.com/adamcalderon
>>I have a datagridview that I populate with the result of a web
service. The webservice sends multiple rows back with each row as
one element of an array. I use a for loop and the bindingsource.Add
method to get the rows into the grid.
That all works fine, but at runtime, the grid wont' allow me to
sort. I have used he smarttage to edit the columns and made sure
that the sortmode is set to "Automatic", but when I click the column
header during runtime, nothing happens.
What am I doing wrong?
Thanks,
Mac