Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TreeListView programmatically expand node after adding child

I use this code to add a child to a BrightIdeasSoftware TreeListView node:

var br = treeListView1.TreeModel.GetBranch(treeListView1.SelectedObject);
((Node)br.Model).Children.Add(new Node(...));
treeListView1.RefreshObject(br.Model);

However, when I try to expand the branch after the above code:

br.Expand();

I get the following error:

Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

Any help with this error?

like image 731
Jerry Avatar asked Sep 13 '25 09:09

Jerry


1 Answers

This worked for me:

treeListView1.Expand(br.Model);
like image 109
Jerry Avatar answered Sep 16 '25 00:09

Jerry