Table of Contents

Class LinearSelector<T>

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

A linear range view that allows selection of a single option from a typed list of options.

public class LinearSelector<T> : LinearRangeViewBase<T, T>, IDisposable, ISupportInitializeNotification, ISupportInitialize, IOrientation, IValue<T>, IValue, IDesignable

Type Parameters

T

The data type of the options.

Inheritance
LinearSelector<T>
Implements
Derived
Inherited Members
Extension Methods

Remarks

Exposes the current selection through Value. When T is a reference type, null unambiguously represents "no selection". When T is a value type, Value is default(T) when no option is selected — which can be indistinguishable from a legitimately selected default value (e.g. 0 for int). To test for empty selection unambiguously for both reference and value types, use SelectedIndex, which is null only when nothing is selected.

To switch the current selection programmatically, set Value or SelectedIndex. To observe selection changes, subscribe to ValueChanged.

Constructors

LinearSelector()

Initializes a new instance of LinearSelector<T>.

LinearSelector(List<T>?, Orientation)

Initializes a new instance of LinearSelector<T>.

Properties

SelectedIndex

Gets or sets the index of the currently selected option, or null if no option is selected. This is the unambiguous "no selection" surface for both reference and value types (compare with Value, where default(T) for value types may collide with a legitimately selected option).

Value

Gets or sets the value.

Methods

EnableForDesign()

Loads demo data suitable for a designer preview: a single-select LinearSelector<T> of T-shirt sizes (XS through XXL) with "M" preselected. Only populated when T is string; for any other type, the view is left untouched and false is returned.

OnSelectionChanged()

Called by the base when the selected indices have changed due to user input. Concrete subclasses must compute their Value from the current selection and raise ValueChanged / ValueChangedUntyped.