Esempio n. 1
0
 /// <summary>
 /// Sets the selection to only the passed item, if it is a possible choice, else selects the first item.
 /// </summary>
 /// <returns>The selected.</returns>
 /// <param name="item">Item.</param>
 public void SetSelected(T item)
 {
     if (_items.Contains(item))
     {
         _selection.Set(item);
     }
     else if (_items.Count > 0)
     {
         _selection.Set(_items[0]);
     }
     else
     {
         _selection.Clear();
     }
 }
Esempio n. 2
0
        /// <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);
        }