Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
995
Unable to sort databound tree nodes...
posted

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 Class Form1
Public dsFilesToBurn As New DataSet("dsFilesToBurn")

Public tbl As New DataTable("FilesToBurn")

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

CreateDataSet()

AddRows()

treeActive.SetDataBinding(dsFilesToBurn,
"FilesToBurn")

treeActive.ExpandAll(ExpandAllType.Always)

'treeActive.Override.SortComparer = New NodeSorter(treeActive.Nodes(1), "Ascending")

'treeActive.Override.Sort = SortType.Ascending

End Sub

Private Sub CreateDataSet()

Dim c As DataColumn

c = New DataColumn("FileName")

With c

.DataType = GetType(String)

End With

tbl.Columns.Add(c)

c =
New DataColumn("FileNameGUID")

With c

.DataType = GetType(String)

End With

tbl.Columns.Add(c)

c =
New DataColumn("FileParentGUID")

With c

.DataType = GetType(String)

End With

tbl.Columns.Add(c)

c =
New DataColumn("FileType")

With c

.DataType = GetType(String)

End With

tbl.Columns.Add(c)

c =
New DataColumn("FileID") With c

c.AllowDBNull = False

c.DataType = GetType(Integer)

c.AutoIncrement = True

c.ReadOnly = True

End With

tbl.Columns.Add(c)

tbl.PrimaryKey =
New DataColumn() {c}

c = New DataColumn("FilePathCD")

c.DataType = GetType(String)

c.MaxLength = 500

tbl.Columns.Add(c)

c =
New DataColumn("FileIcon")c.DataType = GetType(Image)

tbl.Columns.Add(c)

c = New DataColumn("DirGUID")

c.DataType = GetType(String)

c.MaxLength = 50

tbl.Columns.Add(c)

'THIS SHOULD BE SET TO "<SOFTWARE LIBRARY>" IF IT IS FROM THE LIBRARY

'

c = New DataColumn("FilePathLocal")c.DataType = GetType(String)

c.MaxLength = 500

tbl.Columns.Add(c)

c =
New DataColumn("CDGUID")c.DataType = GetType(String)

c.MaxLength = 50

tbl.Columns.Add(c)

c =
New DataColumn("IsDownloaded")c.DataType = GetType(Boolean)

tbl.Columns.Add(c)

c = New DataColumn("FileSizeInt")

c.DataType = GetType(UInteger)

tbl.Columns.Add(c)

c =
New DataColumn("FileSizeStr")c.DataType = GetType(String)

tbl.Columns.Add(c)

dsFilesToBurn.Tables.Add(tbl)

Dim dr As New DataRelation("dr", tbl.Columns("FileNameGUID"), tbl.Columns("FileParentGUID"))

dsFilesToBurn.Relations.Add(dr)

End Sub

Private Sub AddRows() Dim r As DataRow = dsFilesToBurn.Tables(0).NewRow

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("FileType") = "Folder"

r("FileNameGUID") = "1222"

r("FileParentGUID") = "1234"

 

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "BrownFile.exe"

r("FileType") = "File"

r("FileNameGUID") = "1212"

r("FileParentGUID") = "1234"

r("FileSizeStr") = "54.2 MB"

r("FileSizeInt") = 56623104

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "ADumbFile.exe"

r("FileType") = "File"

r("FileNameGUID") = "1616"

r("FileParentGUID") = "1234"

r("FileSizeStr") = "54.2 MB"

r("FileSizeInt") = 56623104

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "CoolFile.exe"

r("FileType") = "File"

r("FileNameGUID") = "1414"

r("FileParentGUID") = "1222"

r("FileSizeStr") = "54.2 MB"

r("FileSizeInt") = 56623104

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "A New File.abc"

r("FileType") = "File"

r("FileNameGUID") = "1111"

r("FileParentGUID") = "1222"

r("FileSizeStr") = "13.4 MB"

r("FileSizeInt") = 14050914

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "ABigFle.123"

r("FileType") = "File"

r("FileNameGUID") = "1223"

r("FileParentGUID") = "1222"

r("FileSizeStr") = "700 MB"

r("FileSizeInt") = 734003200

dsFilesToBurn.Tables(0).Rows.Add(r)

 

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "NewAFile.exe"

r("FileType") = "File"

r("FileNameGUID") = "1515"

r("FileParentGUID") = "1222"

r("FileSizeStr") = "54.2 MB"

r("FileSizeInt") = 56623104

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "JohnsFile.exe"

r("FileType") = "File"

r("FileNameGUID") = "1717"

r("FileParentGUID") = "1222"

r("FileSizeStr") = "54.2 MB"

r("FileSizeInt") = 56623104

dsFilesToBurn.Tables(0).Rows.Add(r)

r = dsFilesToBurn.Tables(0).NewRow

r("FileName") = "Some File.exe"

r("FileType") = "File"

r("FileNameGUID") = "1181"

r("FileParentGUID") = "1222"

r("FileSizeStr") = "54.2 MB"

r("FileSizeInt") = 56623104

dsFilesToBurn.Tables(0).Rows.Add(r)

End Sub

Private Sub treeActive_InitializeDataNode(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinTree.InitializeDataNodeEventArgs) Handles treeActive.InitializeDataNode

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

End If

Catch

End Try

Try

'JUST TRY TO SORT EVERYTHING ASCENDING

e.Node.Override.Sort = SortType.Ascending

Catch ex As Exception

End Try

End Sub

End Class