Exemple #1
0
        public void AddItem()
        {
            DataItem parent = (DataItem)TreeView.SelectedItem;

            if (parent == null)
            {
                parent = TreeView.Items.OfType <DataItem>().First();
            }

            for (int i = 0; i < 1; i++)
            {
                DataItem item = new DataItem("New Item " + i);
                item.Parent = parent;
                parent.Children.Add(item);
            }

            VirtualizingItemContainer itemContainer = TreeView.GetItemContainer(parent);

            if (itemContainer != null)
            {
                //Update arrow visiblity
                TreeView.DataBindItem(parent, itemContainer);
                TreeView.Expand(parent);
            }
        }
        public static void ExpandTo <T>(this VirtualizingTreeView treeView, T item, Func <T, T> getParent)
        {
            if (item == null)
            {
                return;
            }
            ItemContainerData containerData = treeView.GetItemContainerData(item);

            if (containerData == null)
            {
                treeView.ExpandTo(getParent(item), getParent);
                treeView.Expand(item);
            }
            else
            {
                treeView.Expand(item);
            }
        }
 public static void ExpandTo <T>(
     this VirtualizingTreeView treeView,
     T item,
     Func <T, T> getParent)
 {
     if ((object)item == null)
     {
         return;
     }
     if (treeView.GetItemContainerData((object)item) == null)
     {
         treeView.ExpandTo <T>(getParent(item), getParent);
         treeView.Expand((object)item);
     }
     else
     {
         treeView.Expand((object)item);
     }
 }
        public void AddItem()
        {
            DataItem item   = new DataItem("New Item");
            DataItem parent = m_dataItems[m_counter];

            parent.Children.Add(item);

            TreeView.AddChild(parent, item);
            TreeView.Expand(parent);

            DataItem subItem = new DataItem("New Sub Item");

            item.Children.Add(subItem);

            TreeView.AddChild(item, subItem);
            TreeView.Expand(item);

            m_counter++;
            m_counter %= m_dataItems.Count;
        }
        public void Add()
        {
            foreach (DataItem parent in TreeView.SelectedItems)
            {
                DataItem item = new DataItem("New Item");
                parent.Children.Add(item);
                item.Parent = parent;

                TreeView.AddChild(parent, item);
                TreeView.Expand(parent);

                DataItem subItem = new DataItem("New Sub Item");
                item.Children.Add(subItem);
                subItem.Parent = item;

                TreeView.AddChild(item, subItem);
                TreeView.Expand(item);

                m_counter++;
            }
        }
        public static void ExpandChildren <T>(this VirtualizingTreeView treeView, T item, Func <T, IEnumerable> getChildren)
        {
            IEnumerable children = getChildren(item);

            if (children != null)
            {
                treeView.Expand(item);

                foreach (T child in children)
                {
                    treeView.ExpandChildren(child, getChildren);
                }
            }
        }
        public static void ExpandChildren <T>(
            this VirtualizingTreeView treeView,
            T item,
            Func <T, IEnumerable> getChildren)
        {
            IEnumerable enumerable = getChildren(item);

            if (enumerable == null)
            {
                return;
            }
            treeView.Expand((object)item);
            foreach (T obj in enumerable)
            {
                treeView.ExpandChildren <T>(obj, getChildren);
            }
        }