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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sorting and Autocomplete control

Thread ID:





67170 Aug 9,2007 03:45 PM UTC Aug 9,2007 09:54 PM UTC WinForms 1
Tags: Tools
Scott Griswold
Asked On August 9, 2007 03:45 PM UTC


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?


Scott Griswold

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

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.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon