Class TableView
View for tabular data based on a System.Data.DataTable
Inheritance
System.Object
TableView
Implements
System.IDisposable
System.ComponentModel.ISupportInitializeNotification
System.ComponentModel.ISupportInitialize
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Terminal.Gui.dll
Syntax
public class TableView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize
Constructors
TableView()
Declaration
TableView(DataTable)
Declaration
public TableView(DataTable table)
Parameters
Type |
Name |
Description |
System.Data.DataTable |
table |
The table to display in the control |
Fields
DefaultMaxCellWidth
Declaration
public const int DefaultMaxCellWidth = 100
Field Value
Type |
Description |
System.Int32 |
|
Properties
CellActivationKey
The key which when pressed should trigger
CellActivated event. Defaults to Enter.
Declaration
public Key CellActivationKey { get; set; }
Property Value
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
Type |
Description |
System.Int32 |
|
Remarks
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
Type |
Description |
System.Boolean |
|
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
Type |
Description |
System.Int32 |
|
MultiSelect
True to allow regions to be selected
Declaration
public bool MultiSelect { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
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<TableSelection> MultiSelectedRegions { get; }
Property Value
NullSymbol
The text representation that should be rendered for cells with the value System.DBNull.Value
Declaration
public string NullSymbol { get; set; }
Property Value
Type |
Description |
System.String |
|
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
Type |
Description |
System.Int32 |
|
SelectedColumn
The index of
System.Data.DataTable.Columns in
Table that the user has currently selected
Declaration
public int SelectedColumn { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
SelectedRow
The index of
System.Data.DataTable.Rows in
Table that the user has currently selected
Declaration
public int SelectedRow { get; set; }
Property Value
Type |
Description |
System.Int32 |
|
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
Type |
Description |
System.Char |
|
Style
Contains options for changing how the table is rendered
Declaration
public TableStyle Style { get; set; }
Property Value
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
Type |
Description |
System.Data.DataTable |
|
Methods
CellToScreen(Int32, Int32)
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 |
System.Int32 |
tableColumn |
The index of the Table column you are looking for, use System.Data.DataColumn.Ordinal |
System.Int32 |
tableRow |
The index of the row in Table that you are looking for |
Returns
Type |
Description |
System.Nullable<Point> |
|
ChangeSelectionByOffset(Int32, Int32, Boolean)
Declaration
public void ChangeSelectionByOffset(int offsetX, int offsetY, bool extendExistingSelection)
Parameters
Type |
Name |
Description |
System.Int32 |
offsetX |
Offset in number of columns |
System.Int32 |
offsetY |
Offset in number of rows |
System.Boolean |
extendExistingSelection |
True to create a multi cell selection or adjust an existing one |
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()
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()
EnsureValidSelection()
Declaration
public void EnsureValidSelection()
GetAllSelectedCells()
Declaration
public IEnumerable<Point> GetAllSelectedCells()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<Point> |
|
IsSelected(Int32, Int32)
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)
Declaration
public bool IsSelected(int col, int row)
Parameters
Type |
Name |
Description |
System.Int32 |
col |
|
System.Int32 |
row |
|
Returns
Type |
Description |
System.Boolean |
|
MouseEvent(MouseEvent)
Method invoked when a mouse event is generated
Declaration
public override bool MouseEvent(MouseEvent me)
Parameters
Returns
Type |
Description |
System.Boolean |
true , if the event was handled, false otherwise. |
Overrides
OnCellActivated(CellActivatedEventArgs)
Declaration
protected virtual void OnCellActivated(CellActivatedEventArgs args)
Parameters
OnSelectedCellChanged(SelectedCellChangedEventArgs)
Declaration
protected virtual void OnSelectedCellChanged(SelectedCellChangedEventArgs args)
Parameters
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
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
Type |
Description |
System.Boolean |
|
Overrides
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
ScreenToCell(Int32, Int32)
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 |
System.Int32 |
clientX |
X offset from the top left of the control |
System.Int32 |
clientY |
Y offset from the top left of the control |
Returns
Type |
Description |
System.Nullable<Point> |
|
SelectAll()
When
MultiSelect is on, creates selection over all cells in the table (replacing any old selection regions)
Declaration
SetSelection(Int32, Int32, Boolean)
Declaration
public void SetSelection(int col, int row, bool extendExistingSelection)
Parameters
Type |
Name |
Description |
System.Int32 |
col |
|
System.Int32 |
row |
|
System.Boolean |
extendExistingSelection |
True to create a multi cell selection or adjust an existing one |
Update()
Declaration
Events
CellActivated
This event is raised when a cell is activated e.g. by double clicking or pressing
CellActivationKey
Declaration
public event Action<CellActivatedEventArgs> CellActivated
Event Type
SelectedCellChanged
This event is raised when the selected cell in the table changes.
Declaration
public event Action<SelectedCellChangedEventArgs> SelectedCellChanged
Event Type
Implements
System.IDisposable
System.ComponentModel.ISupportInitializeNotification
System.ComponentModel.ISupportInitialize