I have a strange issue that I'm not sure how to work around. Mainly because I can't see what I'm doing wrong.
I'm using a DevExpress TreeList control. I have multiple columns, the main issue is when sorting the columns numerically, the columns are sorted alphabetically, e.g.:
56.2, 57.3, 63.4, 78.9... then 8.3.
So it's sorting it alphabetically. I have set the UnboundType
to Decimal
many times, and changed the SortMode
to Value
and I've tried Default
. I've also tried changing the UnboundType
to Object
. I've also tried changing the FormatMode
to Numeric
, but still this happens. I did find a post on DX but it was useless and is irrelevant to my situation.
Can anybody help? Has anyone experienced this issue before? If you have any idea I would really appreciate it.
Thanks in advance!
Thanks for the reply Marko. I have read that KB already, I have tried setting SortMode: Custom
with the following event handler:
private void trResults_CompareNodeValues(object sender, DevExpress.XtraTreeList.CompareNodeValuesEventArgs e)
{
if (e.Column == colSize)
{
try
{
int value1 = Convert.ToInt32(Regex.Replace((e.NodeValue1 as string), "[^0-9.]", ""));
int value2 = Convert.ToInt32(Regex.Replace((e.NodeValue2 as string), "[^0-9.]", ""));
e.Result = value1 - value2;
}
catch { }
}
}
I have tried it your way, and with my RegEx (which shouldn't have any effect). Here's where it gets even worse; I have set a break point, and guess what, when I sort the columns, it doesn't hit?!
What the hell is up with it!?
Thanks in advance.
It's all good guys. I made a slight error, turns out I didn't wire up the even to the TreeList, foiled by my own idiocracy.