I have a TreeList
reading from a List(Of LedgerAccountEntry)()
.
Public Class LedgerAccountEntry
Public Property LedgerAccountSys() As Integer
Public ParentLedgerAccountSys As Integer
'
'
' ETC
End Class
In form load:
tlLedgerAccounts.ParentFieldName = "ParentLedgerAccountSys"
tlLedgerAccounts.KeyFieldName = "LedgerAccountSys"
tlLedgerAccounts.RootValue = -1
Later on:
While bla
entry.LedgerAccountSys = rstAccounts("LedgerAccountSys").Value
entry.ParentLedgerAccountSys = IIf(rstAccounts("ParentLedgerAccountSys").Value Is DBNull.Value, -1, rstAccounts("ParentLedgerAccountSys").Value)
lst.add(entry)
End While
tlLedgerAccounts.DataSource = lst
These are just the relevant parts. Please let me know if you need more info.
The result is flat tree with no child nodes, I checked that the IDs exists and are being returned correctly.
This is because you are using
ParentLedgerAccountSys
as field. You need to convert yourParentLedgerAccountSys
to property or add another property which represents yourParentLedgerAccountSys
field.Here is example: