I have a simple test here and cannot seem to get the nodes to accept sorting when they are bound. I even tried sorting the DataView of the table and binding to that but still no luck. Here is my example. I have 1 ultratree on the form called treeActive and am calling my Override.Sort =Ascending in the InitializeNode section:
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinTree
Public tbl As New DataTable("FilesToBurn")
CreateDataSet()
AddRows()
treeActive.ExpandAll(ExpandAllType.Always)
'treeActive.Override.SortComparer = New NodeSorter(treeActive.Nodes(1), "Ascending")
'treeActive.Override.Sort = SortType.Ascending
End Sub
Dim c As DataColumn
With c
End With
tbl.Columns.Add(c)
c.AllowDBNull = False
c.AutoIncrement = True
c.ReadOnly = True
c = New DataColumn("FilePathCD")
c.MaxLength = 500
c = New DataColumn("DirGUID")
c.MaxLength = 50
'THIS SHOULD BE SET TO "<SOFTWARE LIBRARY>" IF IT IS FROM THE LIBRARY
'
c = New DataColumn("FileSizeInt")
dsFilesToBurn.Tables.Add(tbl)
dsFilesToBurn.Relations.Add(dr)
r("FileName") = "My InHouse App"
r("FileType") = "Folder"
r("FileNameGUID") = "1234"
dsFilesToBurn.Tables(0).Rows.Add(r)
r = dsFilesToBurn.Tables(0).NewRow
r("FileName") = "MyFile Folder"
r("FileNameGUID") = "1222"
r("FileName") = "BrownFile.exe"
r("FileType") = "File"
r("FileNameGUID") = "1212"
r("FileParentGUID") = "1234"
r("FileSizeStr") = "54.2 MB"
r("FileName") = "ADumbFile.exe"
r("FileNameGUID") = "1616"
r("FileName") = "CoolFile.exe"
r("FileNameGUID") = "1414"
r("FileParentGUID") = "1222"
r("FileName") = "A New File.abc"
r("FileNameGUID") = "1111"
r("FileSizeStr") = "13.4 MB"
r("FileName") = "ABigFle.123"
r("FileNameGUID") = "1223"
r("FileSizeStr") = "700 MB"
r("FileName") = "NewAFile.exe"
r("FileNameGUID") = "1515"
r("FileName") = "JohnsFile.exe"
r("FileNameGUID") = "1717"
r("FileName") = "Some File.exe"
r("FileNameGUID") = "1181"
Try
If e.Node.IsRootLevelNode AndAlso e.Node.HasNodes Then
e.Node.Override.ShowExpansionIndicator = Infragistics.Win.UltraWinTree.ShowExpansionIndicator.CheckOnDisplay
End If
If (e.Node.Level = 0) AndAlso Not (e.Node.Cells("FileParentGUID").Value Is DBNull.Value) Then
e.Node.Visible = False
Else
e.Node.Visible = True
Catch
End Try
'JUST TRY TO SORT EVERYTHING ASCENDING
e.Node.Override.Sort = SortType.Ascending
End Class
Yes, it has to do with ColumnSets. You are probably letting the tree create them automatically - which is what it does by default. So if you want the tree to start off sorted initially, what you could do is handle the ColumnSetGenerated event of the tree. This event will pass you in the ColumnSet that was created. You can examine the columns, find the one you want, and then set the Sort property on it.
Mike Saltzman"]In that case, you have to sort a column
That makes sense. Is there an example of how to sort a column for the tree? I am guessing it has to do with columnsets of something along those lines. I know how to do it in the WinGrid...just not as familar with the tree.
e.Node.Override.Sort only works for node that arein standard view. When you bind the tree and it displays columns, it defaults to grid style. In that case, you have to sort a column, you can't sort a node, since the node itself wouldn't know which field to sort on.