【发布时间】:2013-11-12 21:34:52
【问题描述】:
我正在用文件夹和文件填充分层列表框。 我用这些代码行填充我的列表框:
For i As Integer = 1 To General.GetBlocksFolder.count
If General.GetBlocksFolder.Item(i).Directory Then
frmMain.BlockList.Append(General.GetBlocksFolder.Item(i).DisplayName, True)
frmMain.BlockList.RowTag(i-1) = General.GetBlocksFolder.Item(i).GetSaveInfo(GetFolderItem(""))
End if
Next
General.GetBlocksFolder 是一个在我的系统上保存文件夹信息的对象。 BlockList 是在我的程序中显示“块”的列表。 这按预期工作,我看到了该列表中的文件夹。
然后,当我展开一行时,我使用以下代码:
Dim ItemsAdded as integer
Dim CurrentFolder As FolderItem = General.GetBlocksFolder.GetRelative(me.RowTag(row))
For i As Integer = 1 To CurrentFolder.count
ItemsAdded = ItemsAdded +1
If CurrentFolder.Item(i).Directory Then
frmMain.BlockList.Append(CurrentFolder.Item(i).DisplayName, True)
frmMain.BlockList.RowTag(i+ItemsAdded) = CurrentFolder.Item(i).GetSaveInfo(GetFolderItem(""))
Else
frmMain.BlockList.Append(CurrentFolder.Item(i).DisplayName)
End if
Next
这很好用,但是当我深入到 3 个级别时,我得到一个错误。 'CurrentRow' 上的 nilObjectException
有人知道这是什么魔法吗?
提前致谢 马蒂亚斯
【问题讨论】:
-
很难说。 NilObjectException 发生在哪一行?我没有看到任何关于“CurrentRow”的信息。实际上 Nil 是什么?
-
您的代码令人困惑。没有名为
CurrentRow的变量,ListBox 类也没有Append方法。
标签: listbox hierarchical-data realbasic xojo