Skip to content

Table Class

A scrollable table control.

C#
public class Table : CompositeControl, IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable

Inheritance objectControlBaseCompositeControl

Implements IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable

Creates a new table with the default SadConsole colors, and cell size of (1 width, 1 height)

C#
public Table(int width, int height)

width int

height int

Creates a new table with custom cell width and cell height params; Uses the default SadConsole colors

C#
public Table(int width, int height, int cellWidth, int cellHeight = 1)

width int

height int

cellWidth int

cellHeight int

Creates a new table with extra params to set the base default values of the table

C#
public Table(int width, int height, int cellWidth, Color defaultForeground, Color defaultBackground, int cellHeight = 1)

width int

height int

cellWidth int

defaultForeground SadRogue.Primitives.Color

defaultBackground SadRogue.Primitives.Color

cellHeight int

The cells collection used to modify the table cells

C#
public Table.TableCells Cells { get; }

The default foreground color used for the table foreground and newly created cells

C#
public Color DefaultForeground { get; set; }

The default background color used for the table background and newly created cells

C#
public Color DefaultBackground { get; set; }

The default size a cell gets when it is newly created

C#
public Point DefaultCellSize { get; set; }

The default visual hovering mode when hovering over cells

C#
public Table.TableCells.Layout.Mode DefaultHoverMode { get; set; }

The default visual selection mode when selecting a cell

C#
public Table.TableCells.Layout.Mode DefaultSelectionMode { get; set; }

When true, this object will use the mouse; otherwise false.

C#
public bool UseMouse { get; set; }

Returns the cell the mouse is over, if UseMouse is true.

C#
public Table.Cell? CurrentMouseCell { get; }

Returns the current selected cell

C#
public Table.Cell? SelectedCell { get; }

By default, only cells that have been modified in anyway will be rendered on the table control. Turn this off, if the whole table should draw as many cells as it fits with their default layout.

C#
public bool DrawFakeCells { get; set; }

The vertical scrollbar, use the SetupScrollBar method with Vertical orientation to initialize it.

C#
public ScrollBar? VerticalScrollBar { get; }

The horizontal scrollbar, use the SetupScrollBar method with Horizontal orientation to initialize it.

C#
public ScrollBar? HorizontalScrollBar { get; }

Returns true if the vertical scroll bar is currently visible.

C#
public bool IsVerticalScrollBarVisible { get; }

Returns true if the horizontal scroll bar is currently visible.

C#
public bool IsHorizontalScrollBarVisible { get; }

The updated maximum value, incase the scrollbar object’s maximum value is not yet updated by the theme.

C#
public int VerticalScrollBarMaximum { get; }

The updated maximum value, incase the scrollbar object’s maximum value is not yet updated by the theme.

C#
public int HorizontalScrollBarMaximum { get; }

By default the table will automatically scroll to the selected cell if possible.

C#
public bool AutoScrollOnCellSelection { get; set; }

Configures the associated VerticalScrollBar.

C#
public void SetupScrollBar(Orientation orientation, int size, Point position)

orientation Orientation
The orientation of the scrollbar.

size int

position SadRogue.Primitives.Point
The position of the scrollbar.

Scrolls the list to the item currently selected.

C#
public void ScrollToSelectedItem()

Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.

C#
protected override void OnMouseIn(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.

C#
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Called when the right mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.

C#
protected override void OnRightMouseClicked(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data.

Called when the mouse exits the area of the control. Raises the MouseExit event and calls the DetermineState() method.

C#
protected override void OnMouseExit(ControlBase.ControlMouseState state)

state ControlBase.ControlMouseState
The current mouse data

Updates each control hosted by this control.

C#
public override void UpdateAndRedraw(TimeSpan time)

time TimeSpan
The game frame time delta.

GetOldRowAndColumnValues(List<((int x, int y), (int row, int col))>?, Point, ref int, ref int)

Section titled “GetOldRowAndColumnValues(List<((int x, int y), (int row, int col))>?, Point, ref int, ref int)”
C#
protected void GetOldRowAndColumnValues(List<((int x, int y), (int row, int col))>? fakeCells, Point cellPosition, ref int oldRow, ref int oldCol)

fakeCells List<((int x, int y), (int row, int col))>

cellPosition SadRogue.Primitives.Point

oldRow int

oldCol int

C#
protected void SetScrollBarVisibility(int maxRowsHeight, int maxColumnsWidth)

maxRowsHeight int

maxColumnsWidth int

C#
protected ColoredGlyphBase? GetCustomStateAppearance(Table.Cell cell)

cell Table.Cell

ColoredGlyphBase

AdjustControlSurface(Cell, ColoredGlyphBase?, bool)

Section titled “AdjustControlSurface(Cell, ColoredGlyphBase?, bool)”
C#
protected void AdjustControlSurface(Table.Cell cell, ColoredGlyphBase? customStateAppearance, bool adjustVisibility)

cell Table.Cell

customStateAppearance ColoredGlyphBase

adjustVisibility bool

C#
protected void HideVisualCell(int column, int row, Point position)

column int

row int

position SadRogue.Primitives.Point

C#
protected void PrintText(Table.Cell cell)

cell Table.Cell

GetTotalCellSize(Cell, int, int, out int, out int)

Section titled “GetTotalCellSize(Cell, int, int, out int, out int)”
C#
protected static void GetTotalCellSize(Table.Cell cell, int width, int height, out int totalWidth, out int totalHeight)

cell Table.Cell

width int

height int

totalWidth int

totalHeight int

GetHorizontalAlignment(HorizontalAlign, int, char[])

Section titled “GetHorizontalAlignment(HorizontalAlign, int, char[])”
C#
protected static int GetHorizontalAlignment(Table.Cell.Options.HorizontalAlign hAlign, int totalWidth, char[] textArr)

hAlign Table.Cell.Options.HorizontalAlign

totalWidth int

textArr char[]

int

Fires an event when a cell is entered by the mouse.

C#
public event EventHandler<Table.CellEventArgs>? OnCellEnter

EventHandler<Table.CellEventArgs>

Fires an event when a cell is exited by the mouse.

C#
public event EventHandler<Table.CellEventArgs>? OnCellExit

EventHandler<Table.CellEventArgs>

Fires an event when the selected cell has changed.

C#
public event EventHandler<Table.CellChangedEventArgs>? SelectedCellChanged

EventHandler<Table.CellChangedEventArgs>

Fires an event when a cell is left clicked.

C#
public event EventHandler<Table.CellEventArgs>? OnCellLeftClick

EventHandler<Table.CellEventArgs>

Fires an event when a cell is right clicked.

C#
public event EventHandler<Table.CellEventArgs>? OnCellRightClick

EventHandler<Table.CellEventArgs>

Fires an event when a cell is double clicked.

C#
public event EventHandler<Table.CellEventArgs>? OnCellDoubleClick

EventHandler<Table.CellEventArgs>

Called when a fake cells is being drawn, you can use this to modify the cell layout.

C#
public event EventHandler<Table.CellEventArgs>? OnDrawFakeCell

EventHandler<Table.CellEventArgs>