DevExpress TreeList不显示子节点并显示为根节点

时间:2015-08-26 00:59:03

标签: vb.net winforms devexpress treelist xtratreelist

我从TreeList读取List(Of LedgerAccountEntry)()

Public Class LedgerAccountEntry
    Public Property LedgerAccountSys() As Integer 
    Public ParentLedgerAccountSys As Integer
    '
    '
    ' ETC
End Class

在表单加载中:

tlLedgerAccounts.ParentFieldName = "ParentLedgerAccountSys"
tlLedgerAccounts.KeyFieldName = "LedgerAccountSys"
tlLedgerAccounts.RootValue = -1

后来:

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

这些只是相关部分。如果您需要更多信息,请与我们联系。

结果是没有子节点的平面树,我检查了ID是否存在并且正确返回。

1 个答案:

答案 0 :(得分:1)

这是因为您使用ParentLedgerAccountSys作为字段。您需要将ParentLedgerAccountSys转换为属性或添加代表您的ParentLedgerAccountSys字段的其他属性 这是一个例子:

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