Click here to Skip to main content
15,893,904 members
Home / Discussions / C#
   

C#

 
Generalproblem in setting datasource of a usercontrol Pin
saneng6-Mar-08 23:03
saneng6-Mar-08 23:03 
Questionsorting of a string column Pin
Sonia Gupta6-Mar-08 22:58
Sonia Gupta6-Mar-08 22:58 
GeneralRe: sorting of a string column Pin
Laddie6-Mar-08 23:11
Laddie6-Mar-08 23:11 
GeneralRe: sorting of a string column Pin
Pete O'Hanlon6-Mar-08 23:29
mvePete O'Hanlon6-Mar-08 23:29 
QuestionRe: sorting of a string column Pin
Sonia Gupta6-Mar-08 23:34
Sonia Gupta6-Mar-08 23:34 
GeneralRe: sorting of a string column PinPopular
Pete O'Hanlon6-Mar-08 23:37
mvePete O'Hanlon6-Mar-08 23:37 
QuestionRe: sorting of a string column Pin
Leyu7-Mar-08 0:31
Leyu7-Mar-08 0:31 
GeneralRe: sorting of a string column Pin
Luc Pattyn7-Mar-08 1:28
sitebuilderLuc Pattyn7-Mar-08 1:28 
Hi,

I don't think SQL offers the required ordering.

The "natural sort order" as used for file names by Windows Explorer is available through
P/Invoke, so you can implement an IComparer interface like this:

using System.Runtime.InteropServices;	// DllImport
 
/// <summary>
/// Compares two strings while ignoring case and treating sequences of digits as numbers.
/// (static version).
/// </summary>
public static int Compare(string s1, string s2) {
	if (s1!=null && s2!=null) return StrCmpLogicalW(s1, s2);
	else return string.Compare(s1, s2, true);
}
 
[DllImport("shlwapi.dll", CharSet=CharSet.Unicode, ExactSpelling=true)]
private static extern int StrCmpLogicalW(string s1, string s2);


I do not know how you could apply the above to database-based data; I would guess
you need to first fill a DataTable, then somehow get that sorted using the IComparer object.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.


GeneralRe: sorting of a string column [modified] Pin
PIEBALDconsult7-Mar-08 6:24
mvePIEBALDconsult7-Mar-08 6:24 
GeneralAll Textbox Should be Replace with Zero Pin
M Riaz Bashir6-Mar-08 22:41
M Riaz Bashir6-Mar-08 22:41 
GeneralRe: All Textbox Should be Replace with Zero Pin
Giorgi Dalakishvili6-Mar-08 23:14
mentorGiorgi Dalakishvili6-Mar-08 23:14 
GeneralSecuring HTTP Pin
Lucian.Palcu6-Mar-08 22:27
Lucian.Palcu6-Mar-08 22:27 
GeneralRe: Securing HTTP Pin
snorkie7-Mar-08 9:58
professionalsnorkie7-Mar-08 9:58 
GeneralTo generate a pop up from windows service.. Pin
ag466776-Mar-08 21:40
ag466776-Mar-08 21:40 
GeneralRe: To generate a pop up from windows service.. Pin
Leyu6-Mar-08 21:57
Leyu6-Mar-08 21:57 
GeneralRe: To generate a pop up from windows service.. Pin
ag466776-Mar-08 22:13
ag466776-Mar-08 22:13 
GeneralRe: To generate a pop up from windows service.. Pin
Laddie6-Mar-08 22:14
Laddie6-Mar-08 22:14 
Questionfind function of List Pin
Sonia Gupta6-Mar-08 21:37
Sonia Gupta6-Mar-08 21:37 
GeneralRe: find function of List Pin
Christian Graus6-Mar-08 22:00
protectorChristian Graus6-Mar-08 22:00 
GeneralRe: find function of List Pin
Sonia Gupta6-Mar-08 22:03
Sonia Gupta6-Mar-08 22:03 
GeneralRe: find function of List Pin
Christian Graus6-Mar-08 22:08
protectorChristian Graus6-Mar-08 22:08 
GeneralRe: find function of List Pin
darkelv7-Mar-08 3:20
darkelv7-Mar-08 3:20 
GeneralRe: find function of List Pin
Pete O'Hanlon6-Mar-08 22:04
mvePete O'Hanlon6-Mar-08 22:04 
GeneralRe: find function of List Pin
Sonia Gupta6-Mar-08 22:06
Sonia Gupta6-Mar-08 22:06 
GeneralRe: find function of List Pin
Pete O'Hanlon6-Mar-08 22:08
mvePete O'Hanlon6-Mar-08 22:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.