Class TableView
Assembly: Terminal.Gui.dll
Syntax
public class TableView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Constructors
|
Edit this page
View Source
TableView()
Declaration
|
Edit this page
View Source
TableView(DataTable)
Declaration
public TableView(DataTable table)
Parameters
| Type |
Name |
Description |
| DataTable |
table |
The table to display in the control |
Fields
|
Edit this page
View Source
DefaultMaxCellWidth
Declaration
public const int DefaultMaxCellWidth = 100
Field Value
|
Edit this page
View Source
DefaultMinAcceptableWidth
Declaration
public const int DefaultMinAcceptableWidth = 100
Field Value
Properties
|
Edit this page
View Source
CellActivationKey
The key which when pressed should trigger
CellActivated event. Defaults to Enter.
Declaration
public Key CellActivationKey { get; set; }
Property Value
|
Edit this page
View Source
ColumnOffset
Horizontal scroll offset. The index of the first column in
Table to display when when rendering the view.
Declaration
public int ColumnOffset { get; set; }
Property Value
Remarks
|
Edit this page
View Source
FullRowSelect
True to select the entire row at once. False to select individual cells. Defaults to false
Declaration
public bool FullRowSelect { get; set; }
Property Value
|
Edit this page
View Source
MaxCellWidth
The maximum number of characters to render in any given column. This prevents one long column from pushing out all the others
Declaration
public int MaxCellWidth { get; set; }
Property Value
|
Edit this page
View Source
MultiSelect
True to allow regions to be selected
Declaration
public bool MultiSelect { get; set; }
Property Value
|
Edit this page
View Source
MultiSelectedRegions
When
MultiSelect is enabled this property contain all rectangles of selected cells. Rectangles describe column/rows selected in
Table (not screen coordinates)
Declaration
public Stack<TableView.TableSelection> MultiSelectedRegions { get; }
Property Value
|
Edit this page
View Source
NullSymbol
The text representation that should be rendered for cells with the value
Value
Declaration
public string NullSymbol { get; set; }
Property Value
|
Edit this page
View Source
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.
Declaration
public int RowOffset { get; set; }
Property Value
|
Edit this page
View Source
SelectedColumn
The index of
Columns in
Table that the user has currently selected
Declaration
public int SelectedColumn { get; set; }
Property Value
|
Edit this page
View Source
SelectedRow
The index of
Rows in
Table that the user has currently selected
Declaration
public int SelectedRow { get; set; }
Property Value
|
Edit this page
View Source
SeparatorSymbol
The symbol to add after each cell value and header value to visually seperate values (if not using vertical gridlines)
Declaration
public char SeparatorSymbol { get; set; }
Property Value
|
Edit this page
View Source
Style
Contains options for changing how the table is rendered
Declaration
public TableView.TableStyle Style { get; set; }
Property Value
|
Edit this page
View Source
Table
The data table to render in the view. Setting this property automatically updates and redraws the control.
Declaration
public DataTable Table { get; set; }
Property Value
Methods
|
Edit this page
View Source
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
Declaration
public Point? CellToScreen(int tableColumn, int tableRow)
Parameters
| Type |
Name |
Description |
| int |
tableColumn |
The index of the Table column you are looking for, use Ordinal |
| int |
tableRow |
The index of the row in Table that you are looking for |
Returns
|
Edit this page
View Source
ChangeSelectionByOffset(int, int, bool)
Declaration
public void ChangeSelectionByOffset(int offsetX, int offsetY, bool extendExistingSelection)
Parameters
| Type |
Name |
Description |
| int |
offsetX |
Offset in number of columns |
| int |
offsetY |
Offset in number of rows |
| bool |
extendExistingSelection |
True to create a multi cell selection or adjust an existing one |
|
Edit this page
View Source
ChangeSelectionToEndOfRow(bool)
Moves or extends the selection to the last cell in the current row
Declaration
public void ChangeSelectionToEndOfRow(bool extend)
Parameters
| Type |
Name |
Description |
| bool |
extend |
true to extend the current selection (if any) instead of replacing |
|
Edit this page
View Source
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.
Declaration
public void ChangeSelectionToEndOfTable(bool extend)
Parameters
| Type |
Name |
Description |
| bool |
extend |
true to extend the current selection (if any) instead of replacing |
|
Edit this page
View Source
ChangeSelectionToStartOfRow(bool)
Moves or extends the selection to the first cell in the current row
Declaration
public void ChangeSelectionToStartOfRow(bool extend)
Parameters
| Type |
Name |
Description |
| bool |
extend |
true to extend the current selection (if any) instead of replacing |
|
Edit this page
View Source
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.
Declaration
public void ChangeSelectionToStartOfTable(bool extend)
Parameters
| Type |
Name |
Description |
| bool |
extend |
true to extend the current selection (if any) instead of replacing |
|
Edit this page
View Source
EnsureSelectedCellIsVisible()
Updates scroll offsets to ensure that the selected cell is visible. Has no effect if
Table has not been set.
Declaration
public void EnsureSelectedCellIsVisible()
|
Edit this page
View Source
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.
Declaration
public void EnsureValidScrollOffsets()
|
Edit this page
View Source
EnsureValidSelection()
Declaration
public void EnsureValidSelection()
|
Edit this page
View Source
GetAllSelectedCells()
Declaration
public IEnumerable<Point> GetAllSelectedCells()
Returns
|
Edit this page
View Source
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.
Declaration
public bool IsSelected(int col, int row)
Parameters
| Type |
Name |
Description |
| int |
col |
|
| int |
row |
|
Returns
|
Edit this page
View Source
MouseEvent(MouseEvent)
Method invoked when a mouse event is generated
Declaration
public override bool MouseEvent(MouseEvent me)
Parameters
Returns
| Type |
Description |
| bool |
true, if the event was handled, false otherwise. |
Overrides
|
Edit this page
View Source
OnCellActivated(CellActivatedEventArgs)
Declaration
protected virtual void OnCellActivated(TableView.CellActivatedEventArgs args)
Parameters
|
Edit this page
View Source
OnSelectedCellChanged(SelectedCellChangedEventArgs)
Declaration
protected virtual void OnSelectedCellChanged(TableView.SelectedCellChangedEventArgs args)
Parameters
|
Edit this page
View Source
PageDown(bool)
Moves the selection down by one page
Declaration
public void PageDown(bool extend)
Parameters
| Type |
Name |
Description |
| bool |
extend |
true to extend the current selection (if any) instead of replacing |
|
Edit this page
View Source
PageUp(bool)
Moves the selection up by one page
Declaration
public void PageUp(bool extend)
Parameters
| Type |
Name |
Description |
| bool |
extend |
true to extend the current selection (if any) instead of replacing |
|
Edit this page
View Source
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
Declaration
public override void PositionCursor()
Overrides
|
Edit this page
View Source
ProcessKey(KeyEvent)
If the view is focused, gives the view a
chance to process the keystroke.
Declaration
public override bool ProcessKey(KeyEvent keyEvent)
Parameters
| Type |
Name |
Description |
| KeyEvent |
keyEvent |
Contains the details about the key that produced the event. |
Returns
Overrides
|
Edit this page
View Source
Redraw(Rect)
Redraws this view and its subviews; only redraws the views that have been flagged for a re-display.
Declaration
public override void Redraw(Rect bounds)
Parameters
| Type |
Name |
Description |
| Rect |
bounds |
The bounds (view-relative region) to redraw. |
Overrides
|
Edit this page
View Source
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
Declaration
protected virtual void RenderCell(Attribute cellColor, string render, bool isPrimaryCell)
Parameters
|
Edit this page
View Source
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.
Declaration
public Point? ScreenToCell(int clientX, int clientY)
Parameters
| Type |
Name |
Description |
| int |
clientX |
X offset from the top left of the control. |
| int |
clientY |
Y offset from the top left of the control. |
Returns
| Type |
Description |
| Point? |
Cell clicked or null. |
|
Edit this page
View Source
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.
Declaration
public Point? ScreenToCell(int clientX, int clientY, out DataColumn headerIfAny)
Parameters
| Type |
Name |
Description |
| int |
clientX |
X offset from the top left of the control. |
| int |
clientY |
Y offset from the top left of the control. |
| DataColumn |
headerIfAny |
If the click is in a header this is the column clicked. |
Returns
| Type |
Description |
| Point? |
Cell clicked or null. |
|
Edit this page
View Source
SelectAll()
When
MultiSelect is on, creates selection over all cells in the table (replacing any old selection regions)
Declaration
|
Edit this page
View Source
SetSelection(int, int, bool)
Declaration
public void SetSelection(int col, int row, bool extendExistingSelection)
Parameters
| Type |
Name |
Description |
| int |
col |
|
| int |
row |
|
| bool |
extendExistingSelection |
True to create a multi cell selection or adjust an existing one |
|
Edit this page
View Source
Update()
Declaration
Events
|
Edit this page
View Source
CellActivated
This event is raised when a cell is activated e.g. by double clicking or pressing
CellActivationKey
Declaration
public event Action<TableView.CellActivatedEventArgs> CellActivated
Event Type
|
Edit this page
View Source
SelectedCellChanged
This event is raised when the selected cell in the table changes.
Declaration
public event Action<TableView.SelectedCellChangedEventArgs> SelectedCellChanged
Event Type
Implements