コード例 #1
0
 public void RemoveItem(HierarchyItem item)
 {
     if (subitems.Remove(item))
     {
         item.Parent = null;
     }
 }
コード例 #2
0
        public void AddItem(HierarchyItem item)
        {
            if (item == null)
            {
                throw new ArgumentException("item");
            }

            if (item.Parent != null)
            {
                throw new InvalidOperationException("item.Parent must be null");
            }

            if (subitems == null)
            {
                subitems = new List <HierarchyItem>();
            }

            item.Parent = this;
            subitems.Add(item);
        }