示例#1
0
 public void RemoveItem(IconListBoxItem item)
 {
     if (item.Selected)
     {
         if (Items.IndexOf(item) != -1 && Items.IndexOf(item) != Items.Count - 1)
         {
             this.SelectedItem = Items[Items.IndexOf(item) + 1];
         }
         else if (Items.Count > 1)
         {
             this.SelectedItem = Items[0];
         }
         else
         {
             this.SelectedItem = null;
         }
     }
     if (Items.IndexOf(item) != -1)
     {
         int indice = Items.IndexOf(item);
         this.Controls.Remove(item);
         y = indice * this.itemHeight;
         if (y == 0)
         {
             y = 1;
         }
         for (int contador = indice + 1; contador < Items.Count; contador++)
         {
             Items[contador].Top = y;
             y += this.itemHeight;
         }
     }
     Items.Remove(item);
 }
示例#2
0
        public void AddItem(string text, Image imagen)
        {
            IconListBoxItem item = new IconListBoxItem();

            item.Text  = text;
            item.Image = imagen;
            AddItem(item, true);
        }
示例#3
0
        private void AddItem(IconListBoxItem item, bool AddToItems)
        {
            if (item == null)
            {
                return;
            }
            item.Parent = this;
            item.Dock   = DockStyle.Top;

            if (AddToItems)
            {
                Items.Add(item);
            }

            this.ControlAdded -= new ControlEventHandler(ControlAñadido);
            if (Handle != null)
            {
                this.Invoke(new DelegadoAñadirItem(añadirItem), new object[] { item });
            }
            this.ControlAdded += new ControlEventHandler(ControlAñadido);

            y += this.itemHeight;
        }
示例#4
0
 public void AddItem(IconListBoxItem item)
 {
     AddItem(item, true);
 }
示例#5
0
 private void añadirItem(IconListBoxItem item)
 {
     this.Controls.Add(item);
     this.Controls.SetChildIndex(item, 0);
 }