private void button_Add_Click(object sender, EventArgs e)
        {
            ICustomCollectionElement _itemToAdd = null;

            try
            {
                //poskušamo narediti inštanco (če ni parameterless konstruktorja, ne bo šlo)
                _itemToAdd = (ICustomCollectionElement)Activator.CreateInstance(typeOfElementsInCollection);
            }
            catch (Exception _exception)
            {
                System.Diagnostics.Debug.WriteLine(_exception.Message);
            }


            if (onItemAdd != null)
            {
                _itemToAdd = this.onItemAdd(_itemToAdd, this.listTmp);
            }


            if (_itemToAdd != null)
            {
                this.listTmp.Add(_itemToAdd);
                AddItem(_itemToAdd);
            }
        }
        private void AddItem(ICustomCollectionElement _iCustomCollectionElement)
        {
            ListViewItem _listViewItem = new ListViewItem();

            _listViewItem.Tag  = _iCustomCollectionElement;
            _listViewItem.Text = GetText(_iCustomCollectionElement);

            listView_Collection.Items.Add(_listViewItem);

            listView_Collection.MultiSelect = false;
            _listViewItem.EnsureVisible();
            _listViewItem.Selected          = true;
            listView_Collection.MultiSelect = true;
        }
        private string GetText(ICustomCollectionElement _iCustomCollectionElement)
        {
            string _itemText = null;

            if (this.getItemText != null)
            {
                _itemText = getItemText(_iCustomCollectionElement, this.list);
            }

            if (string.IsNullOrEmpty(_itemText))
            {
                _itemText = _iCustomCollectionElement.ToString();
            }

            return(_itemText);
        }
Esempio n. 4
0
 protected virtual string OnGetItemText(ICustomCollectionElement _item, IList _currentList)
 {
     return(_item.ToString());
 }
Esempio n. 5
0
 //delegati in eventi iz editor forme - za overridanje
 protected virtual ICustomCollectionElement OnItemAdd(ICustomCollectionElement _itemToAdd, IList _currentList)
 {
     return(_itemToAdd);
 }