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
itemListItem
Returns
AddItem(string, object?)
Adds an item to the list
public ListBuilder AddItem(string text, object? tag = null)
Parameters
Returns
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
Returns
AddItems(IEnumerable<ListItem>)
Adds multiple ListItems to the list
public ListBuilder AddItems(IEnumerable<ListItem> items)
Parameters
itemsIEnumerable<ListItem>
Returns
AddItems(params string[])
Adds multiple items to the list
public ListBuilder AddItems(params string[] items)
Parameters
itemsstring[]
Returns
AutoAdjustWidth(bool)
Enables auto-adjust width based on content
public ListBuilder AutoAdjustWidth(bool autoAdjust = true)
Parameters
autoAdjustbool
Returns
Build()
Builds the list control
public ListControl Build()
Returns
ComplexMode()
Enables Complex selection mode (separate highlight/selection with [x]/[ ] markers). Default.
public ListBuilder ComplexMode()
Returns
MaxVisibleItems(int)
Sets the maximum number of visible items
public ListBuilder MaxVisibleItems(int count)
Parameters
countint
Returns
OnGotFocus(WindowEventHandler<EventArgs>)
Sets the GotFocus event handler with window access
public ListBuilder OnGotFocus(WindowEventHandler<EventArgs> handler)
Parameters
handlerWindowEventHandler<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
handlerEventHandlerThe 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
handlerWindowEventHandler<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
handlerEventHandler<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
handlerWindowEventHandler<ListItem>
Returns
OnItemActivated(EventHandler<ListItem>)
Sets the item activated event handler (Enter key or double-click)
public ListBuilder OnItemActivated(EventHandler<ListItem> handler)
Parameters
handlerEventHandler<ListItem>
Returns
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
handlerWindowEventHandler<int>
Returns
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
handlerEventHandler<int>
Returns
OnLostFocus(WindowEventHandler<EventArgs>)
Sets the LostFocus event handler with window access
public ListBuilder OnLostFocus(WindowEventHandler<EventArgs> handler)
Parameters
handlerWindowEventHandler<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
handlerEventHandlerThe 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
handlerWindowEventHandler<MouseEventArgs>
Returns
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
handlerEventHandler<MouseEventArgs>
Returns
OnSelectedItemChanged(WindowEventHandler<ListItem?>)
Sets the selected item changed event handler with window access
public ListBuilder OnSelectedItemChanged(WindowEventHandler<ListItem?> handler)
Parameters
handlerWindowEventHandler<ListItem>
Returns
OnSelectedItemChanged(EventHandler<ListItem?>)
Sets the selected item changed event handler
public ListBuilder OnSelectedItemChanged(EventHandler<ListItem?> handler)
Parameters
handlerEventHandler<ListItem>
Returns
OnSelectedValueChanged(WindowEventHandler<string?>)
Sets the selected value changed event handler with window access
public ListBuilder OnSelectedValueChanged(WindowEventHandler<string?> handler)
Parameters
handlerWindowEventHandler<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
handlerEventHandler<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
handlerWindowEventHandler<int>
Returns
OnSelectionChanged(EventHandler<int>)
Sets the selection changed event handler (index-based)
public ListBuilder OnSelectionChanged(EventHandler<int> handler)
Parameters
handlerEventHandler<int>
Returns
Selectable(bool)
Sets whether items are selectable
public ListBuilder Selectable(bool selectable = true)
Parameters
selectablebool
Returns
SimpleMode()
Enables Simple selection mode (merged highlight/selection, no markers).
public ListBuilder SimpleMode()
Returns
StickyBottom()
Makes the control stick to the bottom of the window
public ListBuilder StickyBottom()
Returns
StickyTop()
Makes the control stick to the top of the window
public ListBuilder StickyTop()
Returns
Visible(bool)
Sets the visibility
public ListBuilder Visible(bool visible = true)
Parameters
visiblebool
Returns
WithAlignment(HorizontalAlignment)
Sets the horizontal alignment
public ListBuilder WithAlignment(HorizontalAlignment alignment)
Parameters
alignmentHorizontalAlignment
Returns
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
enabledbool
Returns
WithBackgroundColor(Color)
Sets the background color
public ListBuilder WithBackgroundColor(Color color)
Parameters
colorColor
Returns
WithColors(Color, Color)
Sets both background and foreground colors
public ListBuilder WithColors(Color background, Color foreground)
Parameters
backgroundColorforegroundColor
Returns
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
Returns
WithFocusedBackgroundColor(Color)
Sets the focused background color
public ListBuilder WithFocusedBackgroundColor(Color color)
Parameters
colorColor
Returns
WithFocusedColors(Color, Color)
Sets both focused background and foreground colors
public ListBuilder WithFocusedColors(Color background, Color foreground)
Parameters
backgroundColorforegroundColor
Returns
WithFocusedForegroundColor(Color)
Sets the focused foreground color
public ListBuilder WithFocusedForegroundColor(Color color)
Parameters
colorColor
Returns
WithForegroundColor(Color)
Sets the foreground color
public ListBuilder WithForegroundColor(Color color)
Parameters
colorColor
Returns
WithHighlightBackgroundColor(Color)
Sets the highlight background color for selected items
public ListBuilder WithHighlightBackgroundColor(Color color)
Parameters
colorColor
Returns
WithHighlightColors(Color, Color)
Sets both highlight background and foreground colors for selected items
public ListBuilder WithHighlightColors(Color background, Color foreground)
Parameters
backgroundColorforegroundColor
Returns
WithHighlightForegroundColor(Color)
Sets the highlight foreground color for selected items
public ListBuilder WithHighlightForegroundColor(Color color)
Parameters
colorColor
Returns
WithHoverHighlighting(bool)
Sets whether mouse hover highlights items visually. Default: true.
public ListBuilder WithHoverHighlighting(bool enabled = true)
Parameters
enabledbool
Returns
WithMargin(int)
Sets uniform margin
public ListBuilder WithMargin(int margin)
Parameters
marginint
Returns
WithMargin(int, int, int, int)
Sets the margin
public ListBuilder WithMargin(int left, int top, int right, int bottom)
Parameters
Returns
WithMouseWheelScrollSpeed(int)
Sets the number of lines to scroll with mouse wheel. Default: 3.
public ListBuilder WithMouseWheelScrollSpeed(int speed)
Parameters
speedint
Returns
WithName(string)
Sets the control name for lookup
public ListBuilder WithName(string name)
Parameters
namestring
Returns
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
modeListSelectionMode
Returns
WithStickyPosition(StickyPosition)
Sets the sticky position
public ListBuilder WithStickyPosition(StickyPosition position)
Parameters
positionStickyPosition
Returns
WithTag(object)
Sets a tag object
public ListBuilder WithTag(object tag)
Parameters
tagobject
Returns
WithTitle(string)
Sets the list title
public ListBuilder WithTitle(string title)
Parameters
titlestring
Returns
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment
public ListBuilder WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignment
Returns
WithWidth(int)
Sets the width
public ListBuilder WithWidth(int width)
Parameters
widthint
Returns
Operators
implicit operator ListControl(ListBuilder)
Implicit conversion to ListControl
public static implicit operator ListControl(ListBuilder builder)
Parameters
builderListBuilder