Exemplo n.º 1
0
        public void RemoveItemAt(int index)
        {
            if (_items == null || index < 0 || index >= _items.Length)
            {
                return;
            }

            if (_items.Length == 1)
            {
                ClearItems();
                return;
            }

            //if (_items[index] == _removing)
            //    return;

            Suspended            = true;
            _items[index].Parent = null;

            var tmp = new ListboxItem[_items.Length - 1];
            int c   = 0;

            for (int i = 0; i < _items.Length; i++)
            {
                if (i != index)
                {
                    tmp[c++] = _items[i];
                }
            }
            _items = tmp;

            _recalc = true;

            Suspended = false;
        }
Exemplo n.º 2
0
        public void AddItems(ListboxItem[] items)
        {
            if (items == null)
            {
                return;
            }

            Suspended = true;

            for (int i = 0; i < items.Length; i++)
            {
                items[i].Parent = this;
            }

            if (_items == null)
            {
                _items = items;
            }
            else
            {
                var tmp = new ListboxItem[_items.Length + items.Length];
                Array.Copy(_items, tmp, _items.Length);
                Array.Copy(items, 0, tmp, _items.Length, items.Length);
                _items = tmp;
            }

            _recalc = true;

            Suspended = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a number of items to the combo box
        /// </summary>
        /// <param name="items">Items to add</param>
        public void AddItems(ListboxItem[] items)
        {
            if (items == null)
            {
                return;
            }

            Suspended = true;
            try
            {
//for (int i = 0; i < items.Length; i++)
                //    items[i].Parent = this;

                if (_items == null)
                {
                    _items = items;
                }
                else
                {
                    var tmp = new ListboxItem[_items.Length + items.Length];
                    Array.Copy(_items, tmp, _items.Length);
                    Array.Copy(items, 0, tmp, _items.Length, items.Length);
                    _items = tmp;
                }

                if (_selIndex == -1)
                {
                    _selIndex = 0;
                }
            }
            finally
            {
                Suspended = false;
            }
        }
Exemplo n.º 4
0
        public void RemoveItem(ListboxItem item)
        {
            if (_items == null) // || item == _removing)
            {
                return;
            }

            for (int i = 0; i < _items.Length; i++)
            {
                if (_items[i] == item)
                {
                    RemoveItemAt(i);
                    return;
                }
            }
        }
Exemplo n.º 5
0
 public void AddItem(ListboxItem item)
 {
     // Update Array Size
     if (_items == null)
     {
         _items = new[] { item };
     }
     else
     {
         var tmp = new ListboxItem[_items.Length + 1];
         Array.Copy(_items, tmp, _items.Length);
         tmp[tmp.Length - 1] = item;
         _items = tmp;
     }
     item.Parent = this;
     _recalc     = true;
     Invalidate();
 }