I'm populating a hierarchical listbox with folders and files. I fill my listbox with these lines of code:
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 is an object that holds info over a folder on my system. BlockList is a list to show 'blocks' in my program. This works as expected, I see the folders inside that list.
Then, when I expand a row, I use following code:
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
This works nicely, but when I go deeper then 3 levels, I get an error. A nilObjectException on 'CurrentRow'
Anybody knows what kind of sorcery this is?
Thanks in advance Mathias