Esempio n. 1
0
        public virtual void AddChild(TListViewItem parentItem, TListViewItem newItem)
        {
            if (parentItem == newItem)
            {
                return;
            }
            if (parentItem == null || !_items.Contains(parentItem))
            {
                return;
            }
            if (newItem == null || _items.Contains(newItem) || parentItem._children.Contains(newItem))
            {
                return;
            }

            newItem._level     = parentItem._level + 1;
            newItem._parent    = parentItem;
            newItem._controler = this;

            parentItem._children.Add(newItem);
            _items.Add(newItem);

            parentItem.Refresh();
            if (parentItem.IsExpanded())
            {
                parentItem.Collaps();
                parentItem.Expand();
            }
        }
Esempio n. 2
0
        private void _listView_DoubleClick(object sender, EventArgs e)
        {
            if (_listView.SelectedItems.Count < 1)
            {
                return;
            }
            TListViewItem item = _listView.SelectedItems[0] as TListViewItem;

            if (item == null)
            {
                return;
            }

            if (item.IsExpanded())
            {
                item.Collaps();
            }
            else
            {
                item.Expand();
            }
        }
Esempio n. 3
0
        public virtual void Remove(TListViewItem currentItem)
        {
            if (currentItem == null || !_items.Contains(currentItem))
            {
                return;
            }

            bool visible = currentItem._visible;

            currentItem._visible = false;

            if (currentItem.HasChildren())
            {
                currentItem.Collaps();
                foreach (TListViewItem child in currentItem.Children)
                {
                    Remove(child);
                }
            }

            TListViewItem parent = currentItem._parent;

            if (parent != null)
            {
                parent._children.Remove(currentItem);
                if (parent._children.Count < 1)
                {
                    parent.Refresh();
                }
            }

            if (visible)
            {
                _listView.Items.Remove(currentItem);
            }

            _items.Remove(currentItem);
        }