Search Results for

    Show / Hide Table of Contents

    Class TableView

    View for tabular data based on a DataTable. See TableView Deep Dive for more information.
    Inheritance
    object
    Responder
    View
    TableView
    Implements
    IDisposable
    ISupportInitializeNotification
    ISupportInitialize
    Inherited Members
    View.Added
    View.Removed
    View.Enter
    View.Leave
    View.MouseEnter
    View.MouseLeave
    View.MouseClick
    View.CanFocusChanged
    View.EnabledChanged
    View.VisibleChanged
    View.HotKeyChanged
    View.HotKey
    View.HotKeySpecifier
    View.Shortcut
    View.ShortcutTag
    View.ShortcutAction
    View.Data
    View.Driver
    View.Subviews
    View.TabIndexes
    View.TabIndex
    View.TabStop
    View.CanFocus
    View.Id
    View.IsCurrentTop
    View.WantMousePositionReports
    View.WantContinuousButtonPressed
    View.Frame
    View.LayoutStyle
    View.Bounds
    View.X
    View.Y
    View.Width
    View.Height
    View.ForceValidatePosDim
    View.GetMinWidthHeight(out Size)
    View.SetMinWidthHeight()
    View.TextFormatter
    View.SuperView
    View.UpdateTextFormatterText()
    View.ProcessResizeView()
    View.SetNeedsDisplay()
    View.ClearLayoutNeeded()
    View.SetNeedsDisplay(Rect)
    View.SetChildNeedsDisplay()
    View.Add(View)
    View.Add(params View[])
    View.RemoveAll()
    View.Remove(View)
    View.BringSubviewToFront(View)
    View.SendSubviewToBack(View)
    View.SendSubviewBackwards(View)
    View.BringSubviewForward(View)
    View.Clear()
    View.Clear(Rect)
    View.ScreenToView(int, int)
    View.ClipToBounds()
    View.SetClip(Rect)
    View.DrawFrame(Rect, int, bool)
    View.DrawHotString(ustring, Attribute, Attribute)
    View.DrawHotString(ustring, bool, ColorScheme)
    View.Move(int, int, bool)
    View.HasFocus
    View.OnAdded(View)
    View.OnRemoved(View)
    View.OnEnter(View)
    View.OnLeave(View)
    View.Focused
    View.MostFocused
    View.ColorScheme
    View.AddRune(int, int, Rune)
    View.ClearNeedsDisplay()
    View.DrawContent
    View.OnDrawContent(Rect)
    View.DrawContentComplete
    View.OnDrawContentComplete(Rect)
    View.SetFocus()
    View.KeyPress
    View.InvokeKeybindings(KeyEvent)
    View.AddKeyBinding(Key, params Command[])
    View.ReplaceKeyBinding(Key, Key)
    View.ContainsKeyBinding(Key)
    View.ClearKeybindings()
    View.ClearKeybinding(Key)
    View.ClearKeybinding(params Command[])
    View.AddCommand(Command, Func<bool?>)
    View.GetSupportedCommands()
    View.GetKeyFromCommand(params Command[])
    View.ProcessHotKey(KeyEvent)
    View.ProcessColdKey(KeyEvent)
    View.KeyDown
    View.OnKeyDown(KeyEvent)
    View.KeyUp
    View.OnKeyUp(KeyEvent)
    View.EnsureFocus()
    View.FocusFirst()
    View.FocusLast()
    View.FocusPrev()
    View.FocusNext()
    View.LayoutStarted
    View.LayoutComplete
    View.Initialized
    View.LayoutSubviews()
    View.Text
    View.AutoSize
    View.PreserveTrailingSpaces
    View.TextAlignment
    View.VerticalTextAlignment
    View.TextDirection
    View.IsInitialized
    View.IsAdded
    View.Enabled
    View.ClearOnVisibleFalse
    View.Visible
    View.Border
    View.IgnoreBorderPropertyOnRedraw
    View.ToString()
    View.GetAutoSize()
    View.GetHotKeySpecifierLength(bool)
    View.GetTextFormatterBoundsSize()
    View.GetBoundsTextFormatterSize()
    View.OnMouseEnter(MouseEvent)
    View.OnMouseLeave(MouseEvent)
    View.OnMouseEvent(MouseEvent)
    View.OnMouseClick(View.MouseEventArgs)
    View.OnCanFocusChanged()
    View.OnEnabledChanged()
    View.OnVisibleChanged()
    View.Dispose(bool)
    View.BeginInit()
    View.EndInit()
    View.SetWidth(int, out int)
    View.SetHeight(int, out int)
    View.GetCurrentWidth(out int)
    View.GetCurrentHeight(out int)
    View.GetNormalColor()
    View.GetFocusColor()
    View.GetHotNormalColor()
    View.GetTopSuperView()
    Responder.Dispose()
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public class TableView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize

    Constructors

    | Edit this page View Source

    TableView()

    Initialzies a TableView class using Computed layout. Set the Table property to begin editing
    Declaration
    public TableView()
    | Edit this page View Source

    TableView(DataTable)

    Initialzies a TableView class using Computed layout.
    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

    The default maximum cell width for MaxCellWidth and MaxWidth
    Declaration
    public const int DefaultMaxCellWidth = 100
    Field Value
    Type Description
    int
    | Edit this page View Source

    DefaultMinAcceptableWidth

    The default minimum cell width for MinAcceptableWidth
    Declaration
    public const int DefaultMinAcceptableWidth = 100
    Field Value
    Type Description
    int

    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
    Type Description
    Key
    | 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
    Type Description
    int
    Remarks
    This property allows very wide tables to be rendered with horizontal scrolling
    | 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
    Type Description
    bool
    | 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
    Type Description
    int
    | Edit this page View Source

    MultiSelect

    True to allow regions to be selected
    Declaration
    public bool MultiSelect { get; set; }
    Property Value
    Type Description
    bool
    | 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
    Type Description
    Stack<TableView.TableSelection>
    | 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
    Type Description
    string
    | 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
    Type Description
    int
    | 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
    Type Description
    int
    | 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
    Type Description
    int
    | 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
    Type Description
    char
    | Edit this page View Source

    Style

    Contains options for changing how the table is rendered
    Declaration
    public TableView.TableStyle Style { get; set; }
    Property Value
    Type Description
    TableView.TableStyle
    | 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
    Type Description
    DataTable

    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
    Type Description
    Point?
    | Edit this page View Source

    ChangeSelectionByOffset(int, int, bool)

    Moves the SelectedRow and SelectedColumn by the provided offsets. Optionally starting a box selection (see MultiSelect)
    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()
    Remarks
    Changes will not be immediately visible in the display until you call SetNeedsDisplay()
    | Edit this page View Source

    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.
    Declaration
    public void EnsureValidScrollOffsets()
    Remarks
    Changes will not be immediately visible in the display until you call SetNeedsDisplay()
    | Edit this page View Source

    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.
    Declaration
    public void EnsureValidSelection()
    Remarks
    Changes will not be immediately visible in the display until you call SetNeedsDisplay()
    | Edit this page View Source

    GetAllSelectedCells()

    Returns all cells in any MultiSelectedRegions (if MultiSelect is enabled) and the selected cell
    Declaration
    public IEnumerable<Point> GetAllSelectedCells()
    Returns
    Type Description
    IEnumerable<Point>
    Remarks
    Return value is not affected by FullRowSelect (i.e. returned Points are not expanded to include all points on row).
    | 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
    Type Description
    bool
    | Edit this page View Source

    MouseEvent(MouseEvent)

    Method invoked when a mouse event is generated
    Declaration
    public override bool MouseEvent(MouseEvent me)
    Parameters
    Type Name Description
    MouseEvent me
    Returns
    Type Description
    bool true, if the event was handled, false otherwise.
    Overrides
    Responder.MouseEvent(MouseEvent)
    | Edit this page View Source

    OnCellActivated(CellActivatedEventArgs)

    Invokes the CellActivated event
    Declaration
    protected virtual void OnCellActivated(TableView.CellActivatedEventArgs args)
    Parameters
    Type Name Description
    TableView.CellActivatedEventArgs args
    | Edit this page View Source

    OnSelectedCellChanged(SelectedCellChangedEventArgs)

    Invokes the SelectedCellChanged event
    Declaration
    protected virtual void OnSelectedCellChanged(TableView.SelectedCellChangedEventArgs args)
    Parameters
    Type Name Description
    TableView.SelectedCellChangedEventArgs args
    | 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
    View.PositionCursor()
    | 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
    Type Description
    bool
    Overrides
    View.ProcessKey(KeyEvent)
    Remarks

    Views can override this method if they are interested in processing the given keystroke. If they consume the keystroke, they must return true to stop the keystroke from being processed by other widgets or consumed by the widget engine. If they return false, the keystroke will be passed using the ProcessColdKey method to other views to process.

    The View implementation does nothing but return false, so it is not necessary to call base.ProcessKey if you derive directly from View, but you should if you derive other View subclasses.

    | 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
    View.Redraw(Rect)
    Remarks

    Always use Bounds (view-relative) when calling Redraw(Rect), NOT Frame (superview-relative).

    Views should set the color that they want to use on entry, as otherwise this will inherit the last color that was set globally on the driver.

    Overrides of Redraw(Rect) must ensure they do not set Driver.Clip to a clip region larger than the parameter, as this will cause the driver to clip the entire region.

    | 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
    Type Name Description
    Attribute cellColor
    string render
    bool isPrimaryCell
    | 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
    public void SelectAll()
    | Edit this page View Source

    SetSelection(int, int, bool)

    Moves the SelectedRow and SelectedColumn to the given col/row in Table. Optionally starting a box selection (see MultiSelect)
    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()

    Updates the view to reflect changes to Table and to (ColumnOffset / RowOffset) etc
    Declaration
    public void Update()
    Remarks
    This always calls SetNeedsDisplay()

    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
    Type Description
    Action<TableView.CellActivatedEventArgs>
    | 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
    Type Description
    Action<TableView.SelectedCellChangedEventArgs>

    Implements

    IDisposable
    ISupportInitializeNotification
    ISupportInitialize
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX