public void Insert(int pos, InsertPosition position, XmlTreeNode n, bool selectIt) { if (n.Node != null) { this.Insert(pos, position, n.Node); } int i = pos; if (position == InsertPosition.After) i++; if (parent == null) { view.Nodes.Insert(i, n); } else { parent.Nodes.Insert(i, n); if (selectIt && !parent.IsExpanded) { parent.Expand(); // this will change image index of leaf nodes. } } n.Invalidate(); if (selectIt) { view.SelectedNode = n; } }