Within my VB.NET program I am using a Devexpress TreeList v9.2. When I run the program I fill the TreeList from a stored procedure.
When I run the SQL procedure in SQL Management Studio my data is returned the way I want it. For example
- 3
- 6
- 33
- 42
- 54
- 206
- 226
- 733
- 6633
Yet when I run the program and fill the TreeList with the same results from the Stored Procedure I get:
- 206
- 226
- 3
- 33
- 42
- 54
- 6
- 6633
- 733
Do you know what I might be doing wrong??
EDIT:
I do have an 'order by' in my stored procedure. That is why I am getting the right order when I run the stored procedure from within the SQL Management Studio. The order by breaks up the number as substrings (as they could also contain letters) so it appears to be sorted numerically. Somehow it looks like the TreeList is resorting it as Strings rather than keeping it with the original sort order.
EDIT:
I created another column containing numeric data so when I sort the table by this column ascending my data would look how I want it. But even though I sent the SortOrder in the properties it wouldn't sort even though the little triangle appeared in the header of the grid when run.
SOLVED:
I solved this by calling:
- tree.beginSort()
- setting the sortindex to the column I want to sort by to 0 and the others columns to -1:
tree.columns("colName").SortIndex
- setting sortorder of my column to ascending:
tree.columns("colName").SortOrder = SortOrder.Ascending
- tree.endsort()
The treeList's column is bound to a string field. In this case, treeList thinks that this column contains string values and sorts them as strings. To change this behavior, use the Custom Sorting approach provided by the XtraTreeList.