473,322 Members | 1,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

DataGridView SortMode Automatic Doesn't Work

mac
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
Aug 1 '06 #1
3 12586
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

Aug 1 '06 #2
mac
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


Aug 2 '06 #3
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

Aug 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
2
by: George Hester | last post by:
I have a page that loads an applet. It's a cube that is used as a navigation menu. This issue actually happens in both Microsoft Internet Explorer and Netscape. All versions that I know of. And...
5
by: Gary Mayor | last post by:
Hi, If I have the ' character within the javascript:pick command it doesn't work. Is there some sort of way of escaping these characters like in server side languages. function pick(symbol) {...
7
by: Bennett Haselton | last post by:
Is there any way to find a string representing an object's class, which will work in Internet Explorer 6? "typeof" doesn't work -- it returns "object" for all objects: x =...
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
4
by: bbp | last post by:
Hello, In an ASPX page I have a "Quit" button which make a simple redirect in code-behind. This button doesn't work no more since (I think) I moved from the framework 1.0 to 1.1 and it doesn't...
10
by: Sourcerer | last post by:
I wrote this very simple code in .NET VC++. I compiled it on my system, and tried to run it on my friend's computer (he doesn't have the compiler). We both have Windows XP Professional. I have .NET...
0
by: frostbb | last post by:
1st I know about the new DataGridView control. For various reasons we need the IsSelected( ) method of the old DataGrid to work in the upgraded apps. I have a small test app that illustrates the...
1
by: windscar | last post by:
Hello Everybody! I am a beginner that try to learn C++ programming. I work in Linux Ubuntu Karmic Koala (9.10) environment. I got a problem with getchar(). The function works well in a simple...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.