0

我有一个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 是否存在并正确返回。

4

1 回答 1

1

这是因为您使用ParentLedgerAccountSys的是 as 字段。您需要转换您的ParentLedgerAccountSysto 属性或添加另一个代表您的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
于 2015-08-26T06:25:25.857 回答