//--------------------------------- /// <summary> /// Creates deep copy of current object. /// </summary> public ComboboxElement Clone() { ComboboxElement newElement = new ComboboxElement(); newElement.ID = this.ID; newElement.SelectedValue = this.SelectedValue?.Clone(); return newElement; }
//---------------------------------- void ContextMenuItemDeleteExecute(ComboboxElement element) { // If the list is not empty and last element has value //if (ElementsList.Count > 1 && element.IsValueChosen) if (ElementsList.Count > 1 && element.SelectedValue != null) { ElementsList.Remove(element); // If the list was full and item was deleted, the last element must be empty to allow user to add new node. // However, if the last item was already empty, nothing will happen. if (ElementsList.Count <= NodesList.Count - 1 && ElementsList.Last().SelectedValue != null) { ElementsList.Add(new ComboboxElement( ElementsList.Count )); } } }