Class InlineSelectWidget
A reusable single-selection list widget.
public sealed class InlineSelectWidget : InlineWidget, ICliRenderable
- Inheritance
-
InlineSelectWidget
- Implements
- Inherited Members
Constructors
InlineSelectWidget(ICliAppShell, IReadOnlyList<string?>, int?, CliFormattingMode, int?, int?)
Creates a single-selection list widget.
public InlineSelectWidget(ICliAppShell shell, IReadOnlyList<string?> labels, int? preselectIndex = null, CliFormattingMode itemsFormattingMode = CliFormattingMode.Raw, int? minWidth = null, int? maxWidth = null)
Parameters
shellICliAppShell- The shell that supplies the theme, culture, and viewport.
labelsIReadOnlyList<string>- The labels to display; a
nulllabel represents a no-selection row. preselectIndexint?- The initially selected index, or
nullfor the first label. itemsFormattingModeCliFormattingMode- How labels are formatted.
minWidthint?- The optional minimum width in cells.
maxWidthint?- The optional maximum width in cells.
Properties
EmptyStateTextOverride
Optional text displayed when the list contains no items.
public string? EmptyStateTextOverride { get; set; }
Property Value
Labels
The labels currently displayed by the widget.
public IReadOnlyList<string?> Labels { get; }
Property Value
SelectedIndex
The selected index, or
-1 when the list is empty.public int SelectedIndex { get; }
Property Value
SelectedValue
The selected label, or
null for an empty list or a selected no-selection row.public string? SelectedValue { get; }
Property Value
Methods
HandleKey(KeyEvent)
Handles a key. Returns whether it was consumed and any requested dialog result.
public override InlineKeyResult HandleKey(KeyEvent key)
Parameters
keyKeyEvent
Returns
SetItems(IReadOnlyList<string?>, int?)
Replaces the displayed labels and selects an item in the new list.
public void SetItems(IReadOnlyList<string?> labels, int? selectedIndex = null)
Parameters
labelsIReadOnlyList<string>- The replacement labels.
selectedIndexint?- The selected index, or
nullfor the first item.
ToGrid()
Converts the component into a grid for measurement and rendering.
public override CliGrid ToGrid()