PromptPlus

PromptPlus # PromptPlus ## **MultiSelect<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: MultiSelect — Styles →


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


Anatomy of the control

Which cities? Seattle (Length: 7)        ← prompt + live answer (follows the cursor) + ExtraInfo
Type to filter                           ← description (optional / dynamic)
North America                            ← group header (grouped lists)
› [x] Seattle          (Length: 7)       ← focused item (checked) + ExtraInfo
  [ ] New York         (Length: 8)
Asia
  [x] Tokyo            (Length: 5)
Filter: to_                              ← live filter text (when filtering)
Page 1/2                                 ← pagination
Space: check  F2: all  Enter: confirm    ← 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 checked-items summary (BuildCheckedItemsText) — 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
Space Toggle the checkbox of the focused item (runs the check predicate)
Space (on a group header) Toggle every item in that group
F2 Toggle all — check all items, or uncheck them if all are checked
F3 Filter only selected — show only the checked items; press again to leave the view
Enter Confirm the checked set (runs range validation)
Esc Abort → IsAborted == true, Content is an empty array
Any printable character Type to filter, or jump to the next match when filtering is 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. The F2 toggle-all and F3 filter-selected hotkeys are the multi-select additions over Select<T>.

There is no F4 wildcard-selection hotkey — that was dead config (HotKeySelectWildcard) that has since been removed entirely from the codebase, not a feature that belongs to some other control instead.

The physical keys for F2/F3 come from PromptPlus.Config.HotKeyToggleAll and HotKeyFilterAllSelected; both are configurable. See Keyboard Bindings.


Checking items


Filtering

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

When Filter is Disabled (the default), typing a printable character instead jumps focus to the next item whose text starts with that character (wrapping around) — arrow keys still work as normal.


Filter only selected (F3)

F3 toggles a view that shows only the checked items, so the user can review or trim a large selection:


Grouping & separators

Grouped and ungrouped items can be mixed in one list.


Item text & extra info


Selection range & confirmation flow

Pressing Enter:

  1. If Range is set, the count of checked items is validated —
    • fewer than the minimum → the list stays open with a “minimum” error;
    • more than the maximum → the list stays open with a “maximum” error.
  2. Otherwise the control closes and returns the checked items as a T[].

The running error line also updates live as you check/uncheck against the range, so the user sees when the selection becomes valid. In ViewOnly mode, Enter always confirms (there is nothing to validate).


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 MultiSelect<T>
EnabledAbortKey(false) Removes Esc — the user must confirm
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