Programming for windows: TreeView is randomly failing to show newly added nodes on newest questions tagged windows – Stack Overflow

I have a TreeView in WinForm application, and I am using the add, reorder and delete methods to add new nodes, reorder existing nodes and delete old notes.

Sometimes when I add a new item it does net show immediately in the TreeView, but it does show correctly when I add the next node. It seems to happen randomly, so it’s difficult to find the root cause.

Even when the node does not show correctly in the UI, the node count is correct.

TreeView1.BeginUpdate();
TreeView1.Nodes.Add("P1", "Parent");

foreach(User u in items)
{
    if( condition)
    {
        node.Text =u.sNodeText;
        node.Tag = u;
        node.Text = u.sNodeText;
        GetChildren(node);
        TreeView1.Nodes["P1"].Nodes.Add((TreeNode)node.Clone());
    }
}
TreeView1.ExpandAll();
TreeView1.EndUpdate();
TreeView1.Refresh();

Can anyone answer this question? I think the question is not meaningless.
Here is the GetChildren method.

     private void GetChildren(TreeNode node)
    {
        TreeNode Node = null;
        User nodeCat = (User)node.Tag;

        foreach (User  cat in items)
        {
            if (cat.sParentID == nodeCat.sID)
            {
                Node = node.Nodes.Add(cat.sNodeText);
                Node.Tag = cat;
                GetChildren(Node);
            }
        }

See Answers


source: http://stackoverflow.com/questions/11291941/treeview-is-randomly-failing-to-show-newly-added-nodes
Programming for windows: programming-for-windows



online applications demo