Hi Jeff,
Thanks, could u please explain me in detail. I am doing as u told, but not
succeed.
I'll try
If you have a function:
void MyTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
// Clear old node
e.Node.Nodes.Clear();
// Call your function to fill the node being expanded
FillNode(e.Node);
}
void FillNode(TreeNode tnParent)
{
TreeNode tnNew;
// Get the key
int index = (int)tnParent.Tag;
// Get the records to fill the Node
foreach(record recTemp in records)
{
// Create Node
tnNew = new TreeNode(recTemp.name);
// Save key in Tag
tnNew.Tag = recTemp.index;
tnParent.Nodes.Add(tnNew);
}
}
You get the Node being expanded in e.Node - you will need to keep a key of
some sort in the Tag of the Node so you know which node you are filling.
You'll have to edit the FillNode function so it gets the appropriate
records. You also only have to write it once - add your root node when you
form loads then it will call this function when it is expanded.
The only caveat is that you will need to add a dummy node to get the '+'
sign in the TreeView, if so you should clear the node before you call the
FillNode function.