DevExpress TreeList not displaying child nodes and displaying as root nodes instead

主宰稳场 提交于 2019-12-12 02:48:38

问题


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.


回答1:


This is because you are using ParentLedgerAccountSys as field. You need to convert your ParentLedgerAccountSys to property or add another property which represents your ParentLedgerAccountSys field.
Here is example:

Public Class LedgerAccountEntry
    Public Property LedgerAccountSys As Integer
    'Public ParentLedgerAccountSys As Integer <-- Here is field.
    Public Property ParentLedgerAccountSys As Integer '<-- Here is property instead of field.
    '
    '
    ' ETC
End Class


来源:https://stackoverflow.com/questions/32216380/devexpress-treelist-not-displaying-child-nodes-and-displaying-as-root-nodes-inst

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!