Class TableControlBuilder
- Namespace
- SharpConsoleUI.Builders
- Assembly
- SharpConsoleUI.dll
Fluent builder for creating TableControl instances with comprehensive configuration.
public sealed class TableControlBuilder : IControlBuilder<TableControl>
- Inheritance
-
TableControlBuilder
- Implements
- Inherited Members
- Extension Methods
Methods
AddColumn(TableColumn)
Adds a custom column to the table.
public TableControlBuilder AddColumn(TableColumn column)
Parameters
columnTableColumn
Returns
AddColumn(string, TextJustification, int?)
Adds a column to the table.
public TableControlBuilder AddColumn(string header, TextJustification alignment = TextJustification.Left, int? width = null)
Parameters
headerstringalignmentTextJustificationwidthint?
Returns
AddRow(TableRow)
Adds a custom row to the table.
public TableControlBuilder AddRow(TableRow row)
Parameters
rowTableRow
Returns
AddRow(params string[])
Adds a row with the specified cells.
public TableControlBuilder AddRow(params string[] cells)
Parameters
cellsstring[]
Returns
AlignBottom()
Aligns the table to the bottom vertically.
public TableControlBuilder AlignBottom()
Returns
Build()
Builds the TableControl with all configured options.
public TableControl Build()
Returns
CenterHorizontal()
Centers the table horizontally.
public TableControlBuilder CenterHorizontal()
Returns
CenterVertical()
Centers the table vertically.
public TableControlBuilder CenterVertical()
Returns
Centered()
Centers the table horizontally and vertically.
public TableControlBuilder Centered()
Returns
DoubleLine()
Uses double-line border style.
public TableControlBuilder DoubleLine()
Returns
DoubleLineBorder()
Uses double-line border style.
public TableControlBuilder DoubleLineBorder()
Returns
Hidden()
Hides the table.
public TableControlBuilder Hidden()
Returns
HideHeader()
Hides the header row.
public TableControlBuilder HideHeader()
Returns
Interactive()
Enables editing mode (sets ReadOnly to false), allowing inline cell editing and column resizing.
public TableControlBuilder Interactive()
Returns
NoBorder()
Uses no border.
public TableControlBuilder NoBorder()
Returns
OnCellActivated(EventHandler<(int Row, int Column)>)
Wires the CellActivated event handler.
public TableControlBuilder OnCellActivated(EventHandler<(int Row, int Column)> handler)
Parameters
handlerEventHandler<(int Line, int Column)>
Returns
OnCellEditCompleted(EventHandler<(int Row, int Column, string OldValue, string NewValue)>)
Wires the CellEditCompleted event handler.
public TableControlBuilder OnCellEditCompleted(EventHandler<(int Row, int Column, string OldValue, string NewValue)> handler)
Parameters
Returns
OnRightClick(EventHandler<MouseEventArgs>)
Wires the MouseRightClick event handler for context menu support.
public TableControlBuilder OnRightClick(EventHandler<MouseEventArgs> handler)
Parameters
handlerEventHandler<MouseEventArgs>
Returns
OnRowActivated(EventHandler<int>)
Wires the RowActivated event handler.
public TableControlBuilder OnRowActivated(EventHandler<int> handler)
Parameters
handlerEventHandler<int>
Returns
OnSelectedRowChanged(EventHandler<int>)
Wires the SelectedRowChanged event handler.
public TableControlBuilder OnSelectedRowChanged(EventHandler<int> handler)
Parameters
handlerEventHandler<int>
Returns
Rounded()
Uses rounded border style.
public TableControlBuilder Rounded()
Returns
ShowHeader(bool)
Shows or hides the header row.
public TableControlBuilder ShowHeader(bool show = true)
Parameters
showbool
Returns
ShowRowSeparators(bool)
Shows or hides row separators.
public TableControlBuilder ShowRowSeparators(bool show = true)
Parameters
showbool
Returns
SingleLine()
Uses single-line border style.
public TableControlBuilder SingleLine()
Returns
StickyBottom()
Makes the table stick to the bottom during scrolling.
public TableControlBuilder StickyBottom()
Returns
StickyTop()
Makes the table stick to the top during scrolling.
public TableControlBuilder StickyTop()
Returns
StretchHorizontal()
Stretches the table horizontally to fill available width.
public TableControlBuilder StretchHorizontal()
Returns
WithBackgroundColor(Color?)
Sets the background color.
public TableControlBuilder WithBackgroundColor(Color? color)
Parameters
colorColor?
Returns
WithBorderColor(Color)
Sets the border color.
public TableControlBuilder WithBorderColor(Color color)
Parameters
colorColor
Returns
WithBorderStyle(BorderStyle)
Sets the border style.
public TableControlBuilder WithBorderStyle(BorderStyle style)
Parameters
styleBorderStyle
Returns
WithCellNavigation()
Enables cell-level navigation with Tab/Left/Right keys.
public TableControlBuilder WithCellNavigation()
Returns
WithCheckboxMode()
Enables checkbox mode for multi-selection.
public TableControlBuilder WithCheckboxMode()
Returns
WithColors(Color?, Color?)
Sets both foreground and background colors. Pass null to inherit from container.
public TableControlBuilder WithColors(Color? foreground, Color? background)
Parameters
Returns
WithColumnResize()
Enables column resizing by dragging column borders. Implies Interactive().
public TableControlBuilder WithColumnResize()
Returns
WithColumns(params string[])
Adds multiple columns from header names.
public TableControlBuilder WithColumns(params string[] headers)
Parameters
headersstring[]
Returns
WithDataSource(ITableDataSource)
Sets the virtual data source for lazy loading.
public TableControlBuilder WithDataSource(ITableDataSource dataSource)
Parameters
dataSourceITableDataSource
Returns
WithFiltering()
Enables inline filtering with '/' key. Implies Interactive().
public TableControlBuilder WithFiltering()
Returns
WithForegroundColor(Color?)
Sets the foreground (text) color. Pass null to inherit from container.
public TableControlBuilder WithForegroundColor(Color? color)
Parameters
colorColor?
Returns
WithFuzzyFilter()
Enables fuzzy (character-subsequence) filter matching. Implies WithFiltering().
public TableControlBuilder WithFuzzyFilter()
Returns
WithHeaderColors(Color, Color)
Sets the header colors.
public TableControlBuilder WithHeaderColors(Color foreground, Color background)
Parameters
Returns
WithHeight(int)
Sets the explicit height.
public TableControlBuilder WithHeight(int height)
Parameters
heightint
Returns
WithHorizontalAlignment(HorizontalAlignment)
Sets the horizontal alignment.
public TableControlBuilder WithHorizontalAlignment(HorizontalAlignment alignment)
Parameters
alignmentHorizontalAlignment
Returns
WithHorizontalScrollbar(ScrollbarVisibility)
Sets the horizontal scrollbar visibility.
public TableControlBuilder WithHorizontalScrollbar(ScrollbarVisibility visibility)
Parameters
visibilityScrollbarVisibility
Returns
WithInlineEditing()
Enables inline cell editing with F2 to start, Enter to commit, Escape to cancel. Implies Interactive().
public TableControlBuilder WithInlineEditing()
Returns
WithMargin(int)
Sets the margin around the table.
public TableControlBuilder WithMargin(int margin)
Parameters
marginint
Returns
WithMargin(int, int)
Sets the margin with separate horizontal and vertical values.
public TableControlBuilder WithMargin(int horizontal, int vertical)
Parameters
Returns
WithMargin(int, int, int, int)
Sets the margin with individual values.
public TableControlBuilder WithMargin(int left, int top, int right, int bottom)
Parameters
Returns
WithMultiSelect()
Enables multi-selection with Ctrl+Click and Shift+Click.
public TableControlBuilder WithMultiSelect()
Returns
WithName(string)
Sets the control name for lookup.
public TableControlBuilder WithName(string name)
Parameters
namestring
Returns
WithRows(IEnumerable<TableRow>)
Adds multiple rows to the table.
public TableControlBuilder WithRows(IEnumerable<TableRow> rows)
Parameters
rowsIEnumerable<TableRow>
Returns
WithSafeBorder(bool)
Enables safe border characters for compatibility.
public TableControlBuilder WithSafeBorder(bool useSafe = true)
Parameters
useSafebool
Returns
WithSorting()
Enables column sorting by clicking headers.
public TableControlBuilder WithSorting()
Returns
WithStickyPosition(StickyPosition)
Sets the sticky position.
public TableControlBuilder WithStickyPosition(StickyPosition position)
Parameters
positionStickyPosition
Returns
WithTag(object)
Sets the tag for custom data.
public TableControlBuilder WithTag(object tag)
Parameters
tagobject
Returns
WithTitle(string, TextJustification)
Sets the table title.
public TableControlBuilder WithTitle(string title, TextJustification alignment = TextJustification.Center)
Parameters
titlestringalignmentTextJustification
Returns
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment.
public TableControlBuilder WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignment
Returns
WithVerticalScrollbar(ScrollbarVisibility)
Sets the vertical scrollbar visibility.
public TableControlBuilder WithVerticalScrollbar(ScrollbarVisibility visibility)
Parameters
visibilityScrollbarVisibility
Returns
WithVisibility(bool)
Sets the visibility.
public TableControlBuilder WithVisibility(bool visible)
Parameters
visiblebool
Returns
WithWidth(int)
Sets the explicit width.
public TableControlBuilder WithWidth(int width)
Parameters
widthint
Returns
Operators
implicit operator TableControl(TableControlBuilder)
Implicit conversion to TableControl.
public static implicit operator TableControl(TableControlBuilder builder)
Parameters
builderTableControlBuilder