public void clearItems() { if (_items.Count == 0) { return; } _items.Clear(); _selection.clear(); invalidateHierarchy(); }
/// <summary> /// Sets the selection to only the passed item, if it is a possible choice. /// </summary> /// <returns>The selected.</returns> /// <param name="item">Item.</param> public void setSelected(T item) { if (_items.Contains(item)) { _selection.set(item); } else if (_selection.getRequired() && _items.Count > 0) { _selection.set(_items[0]); } else { _selection.clear(); } }
/// <summary> /// Sets the selection to only the passed item, if it is a possible choice. /// </summary> /// <param name="item">Item.</param> public ListBox <T> setSelected(T item) { if (_items.Contains(item)) { _selection.set(item); } else if (_selection.getRequired() && _items.Count > 0) { _selection.set(_items[0]); } else { _selection.clear(); } return(this); }