I am using a TreeColumn in Virtual mode and I want to be able to fetch children nodes asynchronously when the parent node is expanded. However, I am getting an Index out of range exception because in some cases I am returning true in VirtualMode_HasChildren but returning 0 in VirtualMode_GetCount.

The reasoning behind my doing this is that when VirtualMode_HasChildren is called I DON'T KNOW whether this node has children or not because I have not gone to find out (this is a very expensive operation that should only occur when the user expands the parent node). Because of this reason I need all nodes to be expandable (display the [+] next to it) until I really know that there are no children under a node.

If the way I am doing this right now is not the right way, what is the correct way to allow a node to be expandable without specifying whether it has children or how many child nodes it has?

The Index out of range exception happens when a key is pressed. Internally the flygrid attemps to traverse the tree nodes to find a string match to select the node using Node.GetFirst() and node.GetNext()...

GetNext() in turn asks if a node has children and since I am returning true for nodes that "I DO NOT Know" have children, it attemps to create that node and that is where the exception happens. This exception cannot be caught anywhere since it is launched from within Flygrid on a separate thread. Please advice on what to do or fix this checking that even though HasChildren returned true, the child node count returned is greater than 0.