/// <summary> /// Sets the items visible in the select box /// </summary> /// <returns>The items.</returns> /// <param name="newItems">New items.</param> public void SetItems(List <T> newItems) { Insist.IsNotNull(newItems, "newItems cannot be null"); float oldPrefWidth = PreferredWidth; _items.Clear(); _items.AddRange(newItems); _selection.Validate(); _selectBoxList.ListBox.SetItems(_items); Invalidate(); Validate(); if (oldPrefWidth != _prefWidth) { InvalidateHierarchy(); SetSize(_prefWidth, _prefHeight); } }
/// <summary> /// Sets the items visible in the list, clearing the selection if it is no longer valid. If a selection is /// ArraySelection#getRequired(), the first item is selected. /// </summary> /// <param name="newItems">New items.</param> public ListBox <T> SetItems(IList <T> newItems) { Insist.IsNotNull(newItems, "newItems cannot be null"); float oldPrefWidth = _prefWidth, oldPrefHeight = _prefHeight; _items.Clear(); _items.AddRange(newItems); _selection.Validate(); Invalidate(); Validate(); if (oldPrefWidth != _prefWidth || oldPrefHeight != _prefHeight) { InvalidateHierarchy(); SetSize(_prefWidth, _prefHeight); } return(this); }