Table of Contents

Class ListBuilder

Namespace
SharpConsoleUI.Builders
Assembly
SharpConsoleUI.dll

Fluent builder for list controls

public sealed class ListBuilder
Inheritance
ListBuilder
Inherited Members

Methods

AddItem(ListItem)

Adds a ListItem to the list

public ListBuilder AddItem(ListItem item)

Parameters

item ListItem

Returns

ListBuilder

AddItem(string, object?)

Adds an item to the list

public ListBuilder AddItem(string text, object? tag = null)

Parameters

text string
tag object

Returns

ListBuilder

AddItem(string, string, Color?, object?)

Adds an item with icon to the list

public ListBuilder AddItem(string text, string icon, Color? iconColor = null, object? tag = null)

Parameters

text string
icon string
iconColor Color?
tag object

Returns

ListBuilder

AddItems(IEnumerable<ListItem>)

Adds multiple ListItems to the list

public ListBuilder AddItems(IEnumerable<ListItem> items)

Parameters

items IEnumerable<ListItem>

Returns

ListBuilder

AddItems(params string[])

Adds multiple items to the list

public ListBuilder AddItems(params string[] items)

Parameters

items string[]

Returns

ListBuilder

AutoAdjustWidth(bool)

Enables auto-adjust width based on content

public ListBuilder AutoAdjustWidth(bool autoAdjust = true)

Parameters

autoAdjust bool

Returns

ListBuilder

Build()

Builds the list control

public ListControl Build()

Returns

ListControl

ComplexMode()

Enables Complex selection mode (separate highlight/selection with [x]/[ ] markers). Default.

public ListBuilder ComplexMode()

Returns

ListBuilder

MaxVisibleItems(int)

Sets the maximum number of visible items

public ListBuilder MaxVisibleItems(int count)

Parameters

count int

Returns

ListBuilder

OnGotFocus(WindowEventHandler<EventArgs>)

Sets the GotFocus event handler with window access

public ListBuilder OnGotFocus(WindowEventHandler<EventArgs> handler)

Parameters

handler WindowEventHandler<EventArgs>

Handler that receives sender, event data, and window

Returns

ListBuilder

The builder for chaining

OnGotFocus(EventHandler)

Sets the GotFocus event handler

public ListBuilder OnGotFocus(EventHandler handler)

Parameters

handler EventHandler

The event handler to invoke when the list receives focus

Returns

ListBuilder

The builder for chaining

OnHighlightChanged(WindowEventHandler<int>)

Sets the highlight changed event handler with window access. Fires when the highlighted index changes (before selection/activation).

public ListBuilder OnHighlightChanged(WindowEventHandler<int> handler)

Parameters

handler WindowEventHandler<int>

Handler receiving sender, index, and window

Returns

ListBuilder

The builder for chaining

OnHighlightChanged(EventHandler<int>)

Sets the highlight changed event handler for arrow key navigation. Fires when the highlighted index changes (before selection/activation). Use this for real-time preview updates as the user browses items.

public ListBuilder OnHighlightChanged(EventHandler<int> handler)

Parameters

handler EventHandler<int>

The event handler to invoke when highlight changes

Returns

ListBuilder

The builder for chaining

OnItemActivated(WindowEventHandler<ListItem>)

Sets the item activated event handler with window access

public ListBuilder OnItemActivated(WindowEventHandler<ListItem> handler)

Parameters

handler WindowEventHandler<ListItem>

Returns

ListBuilder

OnItemActivated(EventHandler<ListItem>)

Sets the item activated event handler (Enter key or double-click)

public ListBuilder OnItemActivated(EventHandler<ListItem> handler)

Parameters

handler EventHandler<ListItem>

Returns

ListBuilder

OnItemHovered(WindowEventHandler<int>)

Sets the item hovered event handler with window access. The index is the hovered item index, or -1 if mouse left all items.

public ListBuilder OnItemHovered(WindowEventHandler<int> handler)

Parameters

handler WindowEventHandler<int>

Returns

ListBuilder

OnItemHovered(EventHandler<int>)

Sets the item hovered event handler (mouse hover over items). The index is the hovered item index, or -1 if mouse left all items.

public ListBuilder OnItemHovered(EventHandler<int> handler)

Parameters

handler EventHandler<int>

Returns

ListBuilder

OnLostFocus(WindowEventHandler<EventArgs>)

Sets the LostFocus event handler with window access

public ListBuilder OnLostFocus(WindowEventHandler<EventArgs> handler)

Parameters

handler WindowEventHandler<EventArgs>

Handler that receives sender, event data, and window

Returns

ListBuilder

The builder for chaining

OnLostFocus(EventHandler)

Sets the LostFocus event handler

public ListBuilder OnLostFocus(EventHandler handler)

Parameters

handler EventHandler

The event handler to invoke when the list loses focus

Returns

ListBuilder

The builder for chaining

OnMouseDoubleClick(WindowEventHandler<MouseEventArgs>)

Sets the mouse double-click event handler with window access. Fires when an item is double-clicked (before ItemActivated).

public ListBuilder OnMouseDoubleClick(WindowEventHandler<MouseEventArgs> handler)

Parameters

handler WindowEventHandler<MouseEventArgs>

Returns

ListBuilder

OnMouseDoubleClick(EventHandler<MouseEventArgs>)

Sets the mouse double-click event handler. Fires when an item is double-clicked (before ItemActivated).

public ListBuilder OnMouseDoubleClick(EventHandler<MouseEventArgs> handler)

Parameters

handler EventHandler<MouseEventArgs>

Returns

ListBuilder

OnSelectedItemChanged(WindowEventHandler<ListItem?>)

Sets the selected item changed event handler with window access

public ListBuilder OnSelectedItemChanged(WindowEventHandler<ListItem?> handler)

Parameters

handler WindowEventHandler<ListItem>

Returns

ListBuilder

OnSelectedItemChanged(EventHandler<ListItem?>)

Sets the selected item changed event handler

public ListBuilder OnSelectedItemChanged(EventHandler<ListItem?> handler)

Parameters

handler EventHandler<ListItem>

Returns

ListBuilder

OnSelectedValueChanged(WindowEventHandler<string?>)

Sets the selected value changed event handler with window access

public ListBuilder OnSelectedValueChanged(WindowEventHandler<string?> handler)

Parameters

handler WindowEventHandler<string>

Handler that receives sender, event data, and window

Returns

ListBuilder

The builder for chaining

OnSelectedValueChanged(EventHandler<string?>)

Sets the selected value changed event handler

public ListBuilder OnSelectedValueChanged(EventHandler<string?> handler)

Parameters

handler EventHandler<string>

The event handler to invoke when the selected value changes

Returns

ListBuilder

The builder for chaining

OnSelectionChanged(WindowEventHandler<int>)

Sets the selection changed event handler with window access

public ListBuilder OnSelectionChanged(WindowEventHandler<int> handler)

Parameters

handler WindowEventHandler<int>

Returns

ListBuilder

OnSelectionChanged(EventHandler<int>)

Sets the selection changed event handler (index-based)

public ListBuilder OnSelectionChanged(EventHandler<int> handler)

Parameters

handler EventHandler<int>

Returns

ListBuilder

Selectable(bool)

Sets whether items are selectable

public ListBuilder Selectable(bool selectable = true)

Parameters

selectable bool

Returns

ListBuilder

SimpleMode()

Enables Simple selection mode (merged highlight/selection, no markers).

public ListBuilder SimpleMode()

Returns

ListBuilder

StickyBottom()

Makes the control stick to the bottom of the window

public ListBuilder StickyBottom()

Returns

ListBuilder

StickyTop()

Makes the control stick to the top of the window

public ListBuilder StickyTop()

Returns

ListBuilder

Visible(bool)

Sets the visibility

public ListBuilder Visible(bool visible = true)

Parameters

visible bool

Returns

ListBuilder

WithAlignment(HorizontalAlignment)

Sets the horizontal alignment

public ListBuilder WithAlignment(HorizontalAlignment alignment)

Parameters

alignment HorizontalAlignment

Returns

ListBuilder

WithAutoHighlightOnFocus(bool)

Sets whether to auto-highlight on focus gain. When true, the control will highlight the selected item (or first item) when focused. Default: true.

public ListBuilder WithAutoHighlightOnFocus(bool enabled = true)

Parameters

enabled bool

Returns

ListBuilder

WithBackgroundColor(Color)

Sets the background color

public ListBuilder WithBackgroundColor(Color color)

Parameters

color Color

Returns

ListBuilder

WithColors(Color, Color)

Sets both background and foreground colors

public ListBuilder WithColors(Color background, Color foreground)

Parameters

background Color
foreground Color

Returns

ListBuilder

WithDoubleClickActivation(bool, int)

Sets whether double-click activates items and the threshold in milliseconds. Default: enabled with 500ms threshold.

public ListBuilder WithDoubleClickActivation(bool enabled = true, int thresholdMs = 500)

Parameters

enabled bool
thresholdMs int

Returns

ListBuilder

WithFocusedBackgroundColor(Color)

Sets the focused background color

public ListBuilder WithFocusedBackgroundColor(Color color)

Parameters

color Color

Returns

ListBuilder

WithFocusedColors(Color, Color)

Sets both focused background and foreground colors

public ListBuilder WithFocusedColors(Color background, Color foreground)

Parameters

background Color
foreground Color

Returns

ListBuilder

WithFocusedForegroundColor(Color)

Sets the focused foreground color

public ListBuilder WithFocusedForegroundColor(Color color)

Parameters

color Color

Returns

ListBuilder

WithForegroundColor(Color)

Sets the foreground color

public ListBuilder WithForegroundColor(Color color)

Parameters

color Color

Returns

ListBuilder

WithHighlightBackgroundColor(Color)

Sets the highlight background color for selected items

public ListBuilder WithHighlightBackgroundColor(Color color)

Parameters

color Color

Returns

ListBuilder

WithHighlightColors(Color, Color)

Sets both highlight background and foreground colors for selected items

public ListBuilder WithHighlightColors(Color background, Color foreground)

Parameters

background Color
foreground Color

Returns

ListBuilder

WithHighlightForegroundColor(Color)

Sets the highlight foreground color for selected items

public ListBuilder WithHighlightForegroundColor(Color color)

Parameters

color Color

Returns

ListBuilder

WithHoverHighlighting(bool)

Sets whether mouse hover highlights items visually. Default: true.

public ListBuilder WithHoverHighlighting(bool enabled = true)

Parameters

enabled bool

Returns

ListBuilder

WithMargin(int)

Sets uniform margin

public ListBuilder WithMargin(int margin)

Parameters

margin int

Returns

ListBuilder

WithMargin(int, int, int, int)

Sets the margin

public ListBuilder WithMargin(int left, int top, int right, int bottom)

Parameters

left int
top int
right int
bottom int

Returns

ListBuilder

WithMouseWheelScrollSpeed(int)

Sets the number of lines to scroll with mouse wheel. Default: 3.

public ListBuilder WithMouseWheelScrollSpeed(int speed)

Parameters

speed int

Returns

ListBuilder

WithName(string)

Sets the control name for lookup

public ListBuilder WithName(string name)

Parameters

name string

Returns

ListBuilder

WithSelectionMode(ListSelectionMode)

Sets the selection mode (Simple or Complex). Simple: Highlight and selection are merged (like TreeControl). Complex: Highlight and selection are separate (like DropdownControl). Default.

public ListBuilder WithSelectionMode(ListSelectionMode mode)

Parameters

mode ListSelectionMode

Returns

ListBuilder

WithStickyPosition(StickyPosition)

Sets the sticky position

public ListBuilder WithStickyPosition(StickyPosition position)

Parameters

position StickyPosition

Returns

ListBuilder

WithTag(object)

Sets a tag object

public ListBuilder WithTag(object tag)

Parameters

tag object

Returns

ListBuilder

WithTitle(string)

Sets the list title

public ListBuilder WithTitle(string title)

Parameters

title string

Returns

ListBuilder

WithVerticalAlignment(VerticalAlignment)

Sets the vertical alignment

public ListBuilder WithVerticalAlignment(VerticalAlignment alignment)

Parameters

alignment VerticalAlignment

Returns

ListBuilder

WithWidth(int)

Sets the width

public ListBuilder WithWidth(int width)

Parameters

width int

Returns

ListBuilder

Operators

implicit operator ListControl(ListBuilder)

Implicit conversion to ListControl

public static implicit operator ListControl(ListBuilder builder)

Parameters

builder ListBuilder

Returns

ListControl