views:

789

answers:

1

After a node's label is edited in the tree I try to resort the nodes to place the updated item in the right position. I do this by calling .Sort in AfterLabelEdit event handler which causes an infinite loop.

How can I resort the nodes in a treeview after a label has been changed?

+3  A: 

Use BeginInvoke:

    delegate void sort();

    private void treeView1_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
    {
        treeView1.BeginInvoke(new sort(treeView1.Sort));
    }
Chris Persichetti
That worked on my sample.
Aaron Daniels
This works, thank you.
blu