I am german fortunately. My treeview sorts like this:
A
B
C
...
Ä
Ö
....
It should sort like this:
A
Ä
B
C
...
O
Ö
....
...
How can I accomplish that?
I am german fortunately. My treeview sorts like this:
A
B
C
...
Ä
Ö
....
It should sort like this:
A
Ä
B
C
...
O
Ö
....
...
How can I accomplish that?
I'm not sure how your treeview is sorting it's elements. However the following code could easily be modified to suit your particular treeview node sorting method.
You can sort a TreeView using an IComparer, you just need to set the TreeViewNodeSorterProperty.
var letters = new List<string> { "A", "B", "C", "O", "Ä", "Ö" };
IComparer<string> comparer = new StringComparer();
var orderedLetters = letters.OrderBy(x => comparer); // returns "A", "Ä", "B", "C", "O", "Ö"
public class StringComparer : IComparer<string>
{
public int Compare(string x, string y)
{
var comparisonResult = string.Compare(x, y, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace);
var areSameUnderlyingLetters = comparisonResult == 0;
if (areSameUnderlyingLetters)
{
return string.Compare(x, y);
}
return comparisonResult;
}
}