Table of Contents

Class TableView

Namespace
Terminal.Gui
Assembly
Terminal.Gui.dll

View for tabular data based on a DataTable.

See TableView Deep Dive for more information.

public class TableView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Inheritance
TableView
Implements
Inherited Members

Constructors

TableView()

Initialzies a TableView class using Computed layout. Set the Table property to begin editing

TableView(DataTable)

Initialzies a TableView class using Computed layout.

Fields

DefaultMaxCellWidth

The default maximum cell width for MaxCellWidth and MaxWidth

DefaultMinAcceptableWidth

The default minimum cell width for MinAcceptableWidth

Properties

CellActivationKey

The key which when pressed should trigger CellActivated event. Defaults to Enter.

ColumnOffset

Horizontal scroll offset. The index of the first column in Table to display when when rendering the view.

FullRowSelect

True to select the entire row at once. False to select individual cells. Defaults to false

MaxCellWidth

The maximum number of characters to render in any given column. This prevents one long column from pushing out all the others

MultiSelect

True to allow regions to be selected

MultiSelectedRegions

When MultiSelect is enabled this property contain all rectangles of selected cells. Rectangles describe column/rows selected in Table (not screen coordinates)

NullSymbol

The text representation that should be rendered for cells with the value Value

RowOffset

Vertical scroll offset. The index of the first row in Table to display in the first non header line of the control when rendering the view.

SelectedColumn

The index of Columns in Table that the user has currently selected

SelectedRow

The index of Rows in Table that the user has currently selected

SeparatorSymbol

The symbol to add after each cell value and header value to visually seperate values (if not using vertical gridlines)

Style

Contains options for changing how the table is rendered

Table

The data table to render in the view. Setting this property automatically updates and redraws the control.

Methods

CellToScreen(int, int)

Returns the screen position (relative to the control client area) that the given cell is rendered or null if it is outside the current scroll area or no table is loaded

ChangeSelectionByOffset(int, int, bool)

Moves the SelectedRow and SelectedColumn by the provided offsets. Optionally starting a box selection (see MultiSelect)

ChangeSelectionToEndOfRow(bool)

Moves or extends the selection to the last cell in the current row

ChangeSelectionToEndOfTable(bool)

Moves or extends the selection to the final cell in the table (nX,nY). If FullRowSelect is enabled then selection instead moves to (SelectedColumn,nY) i.e. no horizontal scrolling.

ChangeSelectionToStartOfRow(bool)

Moves or extends the selection to the first cell in the current row

ChangeSelectionToStartOfTable(bool)

Moves or extends the selection to the first cell in the table (0,0). If FullRowSelect is enabled then selection instead moves to (SelectedColumn,0) i.e. no horizontal scrolling.

EnsureSelectedCellIsVisible()

Updates scroll offsets to ensure that the selected cell is visible. Has no effect if Table has not been set.

EnsureValidScrollOffsets()

Updates ColumnOffset and RowOffset where they are outside the bounds of the table (by adjusting them to the nearest existing cell). Has no effect if Table has not been set.

EnsureValidSelection()

Updates SelectedColumn, SelectedRow and MultiSelectedRegions where they are outside the bounds of the table (by adjusting them to the nearest existing cell). Has no effect if Table has not been set.

GetAllSelectedCells()

Returns all cells in any MultiSelectedRegions (if MultiSelect is enabled) and the selected cell

IsSelected(int, int)

Returns true if the given cell is selected either because it is the active cell or part of a multi cell selection (e.g. FullRowSelect).

Returns false if Visible is false.
MouseEvent(MouseEvent)

Method invoked when a mouse event is generated

OnCellActivated(CellActivatedEventArgs)

Invokes the CellActivated event

OnSelectedCellChanged(SelectedCellChangedEventArgs)

Invokes the SelectedCellChanged event

PageDown(bool)

Moves the selection down by one page

PageUp(bool)

Moves the selection up by one page

PositionCursor()

Positions the cursor in the area of the screen in which the start of the active cell is rendered. Calls base implementation if active cell is not visible due to scrolling or table is loaded etc

ProcessKey(KeyEvent)

If the view is focused, gives the view a chance to process the keystroke.

Redraw(Rect)

Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.

RenderCell(Attribute, string, bool)

Override to provide custom multi colouring to cells. Use Driver to with AddStr(ustring). The driver will already be in the correct place when rendering and you must render the full render or the view will not look right. For simpler provision of color use ColorGetter For changing the content that is rendered use RepresentationGetter

ScreenToCell(int, int)

. Returns the column and row of Table that corresponds to a given point on the screen (relative to the control client area). Returns null if the point is in the header, no table is loaded or outside the control bounds.

ScreenToCell(int, int, out DataColumn)

. Returns the column and row of Table that corresponds to a given point on the screen (relative to the control client area). Returns null if the point is in the header, no table is loaded or outside the control bounds.

SelectAll()

When MultiSelect is on, creates selection over all cells in the table (replacing any old selection regions)

SetSelection(int, int, bool)

Moves the SelectedRow and SelectedColumn to the given col/row in Table. Optionally starting a box selection (see MultiSelect)

Update()

Updates the view to reflect changes to Table and to (ColumnOffset / RowOffset) etc

Events

CellActivated

This event is raised when a cell is activated e.g. by double clicking or pressing CellActivationKey

SelectedCellChanged

This event is raised when the selected cell in the table changes.