public static void UpdateNodes(TreeGridView tree, TreeGridNodeCollection collection, IList <IListItem> contents) { // Add or overwrite existing items for (int i = 0; i < contents.Count; i++) { if (i < collection.Count) { // Overwrite //if (!contents[i].IsLiteral) ((TreeGridNode)collection[i]).Content = contents[i]; } else { // Add //if (!contents[i].IsLiteral) { TreeGridNode tn = new TreeGridNode(tree, contents[i]); tn.UserRow = false; tn.Update(); collection.Add(tn); } } } // Delete other nodes while (collection.Count > contents.Count) { collection.RemoveAt(collection.Count - 1); } //tree.Update(); // tree.UpdateSelection(); // tree.FullUpdate(); }
public void OnExpanding() { try { if (!populated) { if (this._owner == null) { this._owner = this.Nodes; } foreach (ListItem item in Content.SubItems) { TreeGridNode tn = new TreeGridNode(this._grid, item); tn._owner = Nodes; tn._parent = this; tn.InExpanding = true; tn.UserRow = false; item.Changed += tn.OnContentChanged; tn.Update(); Nodes.Add(tn); } populated = true; //this.IsExpandedOnce = true; // this.Tree.UpdateSelection(); // this.Tree.FullUpdate(); } } catch (System.Exception e) { } }
private static void internalUpdateNodes(object prm) { object[] prms = prm as object[]; TreeGridView tree = prms[0] as TreeGridView; TreeGridNodeCollection collection = prms[1] as TreeGridNodeCollection; IList <ListItem> contents = prms[2] as IList <ListItem>; for (int i = 0; i < contents.Count; i++) { try { if (i < collection.Count) { // Overwrite //if (!contents[i].IsLiteral) ((TreeGridNode)collection[i]).Content = contents[i]; } else { // Add //if (!contents[i].IsLiteral) { TreeGridNode tn = new TreeGridNode(tree, contents[i]); tn.UserRow = false; tn.Update(); collection.Add(tn); } } } catch { } } // Delete other nodes while (collection.Count > contents.Count) { collection.RemoveAt(collection.Count - 1); } }