← Back to Home • Next: TableMultiSelect — Methods →
A paginated, filterable grid with named columns and a checkbox per row — the user checks any number of rows and confirms with Enter.
TableMultiSelect<T> is the multiple-selection sibling of TableSelect<T>. It renders any
collection as a bordered table, but each row carries a checkbox: the user toggles rows with Space,
can be constrained to a minimum/maximum count, and gets back an array of the checked rows. Everything the
single-row table offers — columns, filtering, horizontal scrolling, history, view-only — applies here too.
🔘 Only need one row? Use the TableSelect control — same grid model, single choice.
| Sub-page | What you will find |
|---|---|
| Index (this page) | What it is, when to use it, first examples, the method map |
| Methods | Every fluent method — signature, parameters, defaults, and a snippet |
| Operations | Keyboard, checkboxes, filtering, ranges, scrolling, history, view-only |
| Styles | The TableMultiSelectStyles regions and how to recolor them |
Use TableMultiSelect<T> when… |
Consider instead… |
|---|---|
| The data is tabular and the user checks several rows | — |
| The user picks exactly one row | TableSelect |
| Each item is a single label (no columns) | Select |
| The data is hierarchical | TreeSelect |
using PromptPlusLibrary;
record Product(int Id, string Name, string Category, decimal Price);
var products = new[]
{
new Product(1, "Notebook Pro", "Electronics", 1299.99m),
new Product(2, "Wireless Mouse", "Peripherals", 29.90m),
new Product(3, "4K Monitor", "Electronics", 599.00m),
};
var result = PromptPlus.Controls
.TableMultiSelect<Product>("Select products", "Check all desired items")
.AddColumn("Id", x => x.Id, width: 4, alignment: ColumnAlignment.Right)
.AddColumn("Name", x => x.Name)
.AddColumn("Category", x => x.Category)
.AddColumn("Price", x => x.Price, v => $"$ {v:N2}", alignment: ColumnAlignment.Right)
.AddItems(products)
.Run();
if (!result.IsAborted)
foreach (var product in result.Content) // iterate yields T directly
PromptPlus.Console.WriteLine(product.Name);
TableMultiSelect<Product>(...) creates the grid. The type argument T is the row type..AddColumn(...) is header-first: header text, then a Func<T, object> that extracts the cell
value, then optional formatter / width / alignment / filterable flag..AddItems([...]) fills the rows; .AddItem(x, ischecked, disable) adds one at a time..Run() renders the table and blocks until Enter (confirm) or Esc (abort), returning
ResultPrompt<T[]> — .Content is an array of the checked rows.At least one column and one row must be configured before
Run, otherwise aValidationExceptionis thrown.
using PromptPlusLibrary;
var result = PromptPlus.Controls
.TableMultiSelect<Product>("Select 2 to 4 products", "Available items pre-checked")
.AddColumn("Name", x => x.Name)
.AddColumn("Category", x => x.Category)
.AddColumn("Available", x => x.Available ? "Yes" : "No", alignment: ColumnAlignment.Center, width: 10)
.Interaction(products, (p, ctrl) => ctrl.AddItem(p, ischecked: p.Available, disable: !p.Available))
.Range(minvalue: 2, maxvalue: 4) // must end with 2–4 checked
.TextSelector(item => item.Name)
.Run();
This combines pre-checked rows, a disabled row, and a range constraint — see Operations for how they behave together.
Grouped by purpose. Full signatures and examples are on the Methods page.
| Purpose | Methods |
|---|---|
| Define columns | AddColumn |
| Add rows | AddItem, AddItems |
| Load from a source | Interaction, InteractionAsync |
| Answer text & description | TextSelector, TextSelectorAsync, ChangeDescription, ChangeDescriptionAsync |
| Filtering & paging | Filter, PageSize |
| Layout & borders | LayoutMode, HideElements, HorizontalScroll |
| Checked set & count | Default, Range, UseDefaultHistory, DefaultMatchBy |
| Restrict what can be checked | PredicateChecked, PredicateCheckedAsync |
| Read-only display | ViewOnly |
| History | EnableHistory |
| Appearance & behavior | Styles, Options |
| Run | Run |
TableMultiSelect<T> returns ResultPrompt<T[]> — an array of the checked rows.
| Member | Meaning |
|---|---|
.Content |
The T[] of checked rows (empty array when nothing is checked) |
.IsAborted |
true when the user pressed Esc |
Iterating .Content yields each T directly — there is no .Value wrapper (unlike
TableSelect<T>, which returns a single TableSelectResult<T>).
var result = PromptPlus.Controls.TableMultiSelect<Product>("Products")
.AddColumn("Name", x => x.Name)
.AddItems(products)
.Run();
if (!result.IsAborted)
PromptPlus.Console.WriteLine($"Checked {result.Content.Length}: " +
string.Join(", ", result.Content.Select(p => p.Name)));