We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Sorting and Autocomplete control

Thread ID:

Created:

Updated:

Platform:

Replies:

67170 Aug 9,2007 11:45 AM Aug 9,2007 05:54 PM Windows Forms 1
loading
Tags: Tools
Scott Griswold
Asked On August 9, 2007 11:45 AM

Hello,

I am using autocomplete and a text box control to show a list of integers. The dataset coming off the database shows them correctly sorted, but when displayed in the text box control they are sorted as if they were text. Is there a way to change this to show them sorted as integers?

Thanks,

Scott Griswold

Ajish [Syncfusion]
Replied On August 9, 2007 05:54 PM

Hi Scott,

The default behavior of autocomplete is to do a sort as text, to make a numeric sort and then list the sorted data on the autocomplete you can do that by using IComparer interface. To sort the string in Numeric fashion use the following code

string[] str = NumericComparer ns = new NumericComparer();
Array.Sort(files, ns);

and set the sorted Array as the datasource for Autocomplete. Here is the sample for your reference

Sample: http://websamples.syncfusion.com/samples/Tools.Windows/F67170/main.htm

The class StringLogicalComparer in my C# code emulates StrCmpLogicalW, and NumericComparer is a class implementing the System.Collections.IComparer interface to be used to sort collections. The natural numeric order comparer for strings is defined in a class named NumericComparer : IComparer and can be found in the sample code.

Note : Make sure that you make AutoSortList property of Autocomplete to false before you apply this custom numeric sorted data as datasource.

Kindly take a look and let me know if this helps.

Thanks,
Ajish.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;