PromptPlus

PromptPlus # PromptPlus ## **Select<T> — Operations** [![NuGet](https://img.shields.io/badge/NuGet-PromptPlus-blue)](https://www.nuget.org/packages/PromptPlus) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![.NET](https://img.shields.io/badge/.NET-8%20%7C%209%20%7C%2010-512BD4)](https://dotnet.microsoft.com/)

← Back to HomeNext: Select — Styles →


How the Select<T> control behaves while it is running: keyboard, filtering, grouping, paging, validation, history, and view-only mode.


Anatomy of the control

Which city? Seattle (Length: 7)          ← prompt + live answer (follows the cursor) + ExtraInfo
Type to filter                           ← description (optional / dynamic)
North America                            ← group header (grouped lists)
› Seattle            (Length: 7)         ← focused item + ExtraInfo
  New York           (Length: 8)
Asia
  Tokyo              (Length: 5)
Filter: to_                              ← live filter text (when filtering)
Page 1/2                                 ← pagination
Enter: confirm  Esc: cancel              ← tooltip

The answer line updates as you navigate and includes ExtraInfo/ExtraInfoAsync when set — useful when a row’s own text is too wide for the console and would otherwise be cut off, since this line scrolls horizontally (Home/End//). Once confirmed (Enter), the final answer shown is the plain item text — no ExtraInfo.

Every region can be recolored — see Styles.


Keyboard

Key Action
/ Move focus up / down
Page Up / Page Down Jump one page
Ctrl+Home / Ctrl+End First / last item
Enter Confirm the focused item (runs validation)
Esc Abort → IsAborted == true
Any printable character Type to filter (when Filter is not Disabled)
Backspace Edit the filter text
Home / End / / Scroll the answer line horizontally (when it overflows the width)
F1 Cycle tooltip content
Ctrl+F1 Show / hide the tooltip

Disabled items and separators are skipped automatically as you move.


Filtering

When Filter is Contains or StartsWith, typing narrows the visible list in real time:

Disabled (the default) turns typing off entirely — arrow keys only.


Grouping & separators

Grouped and ungrouped items can be mixed in one list.


Item text & extra info


Confirmation & validation flow

Pressing Enter on the focused item:

  1. Validation runs — PredicateSelected / PredicateSelectedAsync, if configured.
  2. Valid → the control closes and returns the item. Invalid → the list stays open and shows the error line.

Disabled items cannot be focused for confirmation, so validation typically guards business rules (e.g., “this option is not available for your plan”) rather than availability.


Initial selection & history


View-only mode

ViewOnly() renders the list for display only:


Options that change behavior

Set per instance via Options(...), or globally on PromptPlus.Config:

Option Effect on Select<T>
EnabledAbortKey(false) Removes Esc — the user must choose
HideAfterFinish(true) Erases the list after confirm — the whole control is erased, not just the interactive part
ShowTooltip(false) Hides the keyboard hint line
Prompt(...) / Description(...) Overrides the prompt / description text

PageSize can be set per control (PageSize) or globally (PromptPlus.Config.PageSize).


Edge cases & gotchas


See also