Okay, I've been struggling with this forever, and I have no idea why it does this. Here's the problem, short and sweet. I'm filling a treeview with system hWnd's, and every node's key is "H" & hWnd (hence "H1000" as an example with handle 1000).

Now... as the code runs through and gets a new hwnd, it adds it to the treeview like so, and also stores the hwnd to an array called HList, which also holds the hWnd, the ParentHWnd, and other information. Each node's tag is entered as the array index, so they relate.

Here's the problem. After the treeview is filled with all the hWnd's, I want to sort them into their corresponding parents. For this, I use HList and make each node with the corresponding hWnd be set as the child as it's corresponding ParentHWnd. Should work, shouldn't it? Well, yes, it does, atleast not compiled. As soon as I compile it everything gets sorted wrong. From what I can tell, it looks like the parent hwnds that have NO parent (ie ParentHwnd = 0), are somehow made the children of their direct Child... I'm so lost. If anyone has even the slightest idea why the hell it does this, please, respond.

Also, for some reason, "If Treeview1.Node(SomeNodeIndexThatDoesntExist) Is Nothing Then" returns and error. I thought this worked?