Exemple #1
0
        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();
        }
Exemple #2
0
        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);
            }
        }