Search Results for

    Show / Hide Table of Contents

    Class ListView

    ListView View renders a scrollable list of data where each item can be activated to perform an action.
    Inheritance
    System.Object
    Responder
    View
    ListView
    Implements
    System.IDisposable
    System.ComponentModel.ISupportInitializeNotification
    System.ComponentModel.ISupportInitialize
    Remarks

    The ListView displays lists of data and allows the user to scroll through the data. Items in the can be activated firing an event (with the ENTER key or a mouse double-click). If the AllowsMarking property is true, elements of the list can be marked by the user.

    By default ListView uses System.Object.ToString() to render the items of any System.Collections.IList object (e.g. arrays, System.Collections.Generic.List<T>, and other collections). Alternatively, an object that implements IListDataSource can be provided giving full control of what is rendered.

    ListView can display any object that implements the System.Collections.IList interface. System.String values are converted into values before rendering, and other values are converted into System.String by calling System.Object.ToString() and then converting to .

    To change the contents of the ListView, set the Source property (when providing custom rendering via IListDataSource) or call SetSource(IList) an System.Collections.IList is being used.

    When AllowsMarking is set to true the rendering will prefix the rendered items with [x] or [ ] and bind the SPACE key to toggle the selection. To implement a different marking style set AllowsMarking to false and implement custom rendering.

    Searching the ListView with the keyboard is supported. Users type the first characters of an item, and the first item that starts with what the user types will be selected.

    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(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(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(Int32, Int32)
    View.ClipToBounds()
    View.SetClip(Rect)
    View.DrawFrame(Rect, Int32, Boolean)
    View.DrawHotString(ustring, Attribute, Attribute)
    View.DrawHotString(ustring, Boolean, ColorScheme)
    View.Move(Int32, Int32, Boolean)
    View.HasFocus
    View.OnAdded(View)
    View.OnRemoved(View)
    View.Focused
    View.MostFocused
    View.ColorScheme
    View.AddRune(Int32, Int32, Rune)
    View.ClearNeedsDisplay()
    View.DrawContent
    View.OnDrawContent(Rect)
    View.DrawContentComplete
    View.OnDrawContentComplete(Rect)
    View.SetFocus()
    View.KeyPress
    View.InvokeKeybindings(KeyEvent)
    View.AddKeyBinding(Key, Command[])
    View.ReplaceKeyBinding(Key, Key)
    View.ContainsKeyBinding(Key)
    View.ClearKeybindings()
    View.ClearKeybinding(Key)
    View.ClearKeybinding(Command[])
    View.AddCommand(Command, Func<Nullable<Boolean>>)
    View.GetSupportedCommands()
    View.GetKeyFromCommand(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(Boolean)
    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(Boolean)
    View.BeginInit()
    View.EndInit()
    View.SetWidth(Int32, Int32)
    View.SetHeight(Int32, Int32)
    View.GetCurrentWidth(Int32)
    View.GetCurrentHeight(Int32)
    View.GetNormalColor()
    View.GetFocusColor()
    View.GetHotNormalColor()
    View.GetTopSuperView()
    Responder.Dispose()
    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)
    Namespace: Terminal.Gui
    Assembly: Terminal.Gui.dll
    Syntax
    public class ListView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize

    Constructors

    | Improve this Doc View Source

    ListView()

    Initializes a new instance of ListView. Set the Source property to display something.
    Declaration
    public ListView()
    | Improve this Doc View Source

    ListView(IList)

    Initializes a new instance of ListView that will display the contents of the object implementing the System.Collections.IList interface, with relative positioning.
    Declaration
    public ListView(IList source)
    Parameters
    Type Name Description
    System.Collections.IList source An System.Collections.IList data source, if the elements are strings or ustrings, the string is rendered, otherwise the ToString() method is invoked on the result.
    | Improve this Doc View Source

    ListView(IListDataSource)

    Initializes a new instance of ListView that will display the provided data source, using relative positioning.
    Declaration
    public ListView(IListDataSource source)
    Parameters
    Type Name Description
    IListDataSource source IListDataSource object that provides a mechanism to render the data. The number of elements on the collection should not change, if you must change, set the "Source" property to reset the internal settings of the ListView.
    | Improve this Doc View Source

    ListView(Rect, IList)

    Initializes a new instance of ListView that will display the contents of the object implementing the System.Collections.IList interface with an absolute position.
    Declaration
    public ListView(Rect rect, IList source)
    Parameters
    Type Name Description
    Rect rect Frame for the listview.
    System.Collections.IList source An IList data source, if the elements of the IList are strings or ustrings, the string is rendered, otherwise the ToString() method is invoked on the result.
    | Improve this Doc View Source

    ListView(Rect, IListDataSource)

    Initializes a new instance of ListView with the provided data source and an absolute position
    Declaration
    public ListView(Rect rect, IListDataSource source)
    Parameters
    Type Name Description
    Rect rect Frame for the listview.
    IListDataSource source IListDataSource object that provides a mechanism to render the data. The number of elements on the collection should not change, if you must change, set the "Source" property to reset the internal settings of the ListView.

    Properties

    | Improve this Doc View Source

    AllowsMarking

    Gets or sets whether this ListView allows items to be marked.
    Declaration
    public bool AllowsMarking { get; set; }
    Property Value
    Type Description
    System.Boolean Set to true to allow marking elements of the list.
    | Improve this Doc View Source

    AllowsMultipleSelection

    If set to true more than one item can be selected. If false selecting an item will cause all others to be un-selected. The default is false.
    Declaration
    public bool AllowsMultipleSelection { get; set; }
    Property Value
    Type Description
    System.Boolean
    | Improve this Doc View Source

    KeystrokeNavigator

    Gets the CollectionNavigator that searches the Source collection as the user types.
    Declaration
    public CollectionNavigator KeystrokeNavigator { get; }
    Property Value
    Type Description
    CollectionNavigator
    | Improve this Doc View Source

    LeftItem

    Gets or sets the leftmost column that is currently visible (when scrolling horizontally).
    Declaration
    public int LeftItem { get; set; }
    Property Value
    Type Description
    System.Int32 The left position.
    | Improve this Doc View Source

    Maxlength

    Gets the widest item in the list.
    Declaration
    public int Maxlength { get; }
    Property Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    SelectedItem

    Gets or sets the index of the currently selected item.
    Declaration
    public int SelectedItem { get; set; }
    Property Value
    Type Description
    System.Int32 The selected item.
    | Improve this Doc View Source

    Source

    Gets or sets the IListDataSource backing this ListView, enabling custom rendering.
    Declaration
    public IListDataSource Source { get; set; }
    Property Value
    Type Description
    IListDataSource The source.
    | Improve this Doc View Source

    TopItem

    Gets or sets the item that is displayed at the top of the ListView.
    Declaration
    public int TopItem { get; set; }
    Property Value
    Type Description
    System.Int32 The top item.

    Methods

    | Improve this Doc View Source

    AllowsAll()

    If AllowsMarking and AllowsMultipleSelection are both true, unmarks all marked items other than the currently selected.
    Declaration
    public virtual bool AllowsAll()
    Returns
    Type Description
    System.Boolean true if unmarking was successful.
    | Improve this Doc View Source

    EnsureSelectedItemVisible()

    Ensures the selected item is always visible on the screen.
    Declaration
    public void EnsureSelectedItemVisible()
    | Improve this Doc View Source

    MarkUnmarkRow()

    Marks the SelectedItem if it is not already marked.
    Declaration
    public virtual bool MarkUnmarkRow()
    Returns
    Type Description
    System.Boolean true if the SelectedItem was marked.
    | Improve this Doc 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
    System.Boolean true, if the event was handled, false otherwise.
    Overrides
    Responder.MouseEvent(MouseEvent)
    | Improve this Doc View Source

    MoveDown()

    Changes the SelectedItem to the next item in the list, scrolling the list if needed.
    Declaration
    public virtual bool MoveDown()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MoveEnd()

    Changes the SelectedItem to last item in the list, scrolling the list if needed.
    Declaration
    public virtual bool MoveEnd()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MoveHome()

    Changes the SelectedItem to the first item in the list, scrolling the list if needed.
    Declaration
    public virtual bool MoveHome()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MovePageDown()

    Changes the SelectedItem to the item just below the bottom of the visible list, scrolling if needed.
    Declaration
    public virtual bool MovePageDown()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MovePageUp()

    Changes the SelectedItem to the item at the top of the visible list.
    Declaration
    public virtual bool MovePageUp()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    MoveUp()

    Changes the SelectedItem to the previous item in the list, scrolling the list if needed.
    Declaration
    public virtual bool MoveUp()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    OnEnter(View)

    Method invoked when a view gets focus.
    Declaration
    public override bool OnEnter(View view)
    Parameters
    Type Name Description
    View view The view that is losing focus.
    Returns
    Type Description
    System.Boolean true, if the event was handled, false otherwise.
    Overrides
    View.OnEnter(View)
    | Improve this Doc View Source

    OnLeave(View)

    Method invoked when a view loses focus.
    Declaration
    public override bool OnLeave(View view)
    Parameters
    Type Name Description
    View view The view that is getting focus.
    Returns
    Type Description
    System.Boolean true, if the event was handled, false otherwise.
    Overrides
    View.OnLeave(View)
    | Improve this Doc View Source

    OnOpenSelectedItem()

    Invokes the OpenSelectedItem event if it is defined.
    Declaration
    public virtual bool OnOpenSelectedItem()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    OnRowRender(ListViewRowEventArgs)

    Virtual method that will invoke the RowRender.
    Declaration
    public virtual void OnRowRender(ListViewRowEventArgs rowEventArgs)
    Parameters
    Type Name Description
    ListViewRowEventArgs rowEventArgs
    | Improve this Doc View Source

    OnSelectedChanged()

    Invokes the SelectedItemChanged event if it is defined.
    Declaration
    public virtual bool OnSelectedChanged()
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    PositionCursor()

    Positions the cursor in the right position based on the currently focused view in the chain.
    Declaration
    public override void PositionCursor()
    Overrides
    View.PositionCursor()
    | Improve this Doc View Source

    ProcessKey(KeyEvent)

    If the view is focused, gives the view a chance to process the keystroke.
    Declaration
    public override bool ProcessKey(KeyEvent kb)
    Parameters
    Type Name Description
    KeyEvent kb
    Returns
    Type Description
    System.Boolean
    Overrides
    View.ProcessKey(KeyEvent)
    | Improve this Doc 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)
    | Improve this Doc View Source

    ScrollDown(Int32)

    Scrolls the view down by items items.
    Declaration
    public virtual bool ScrollDown(int items)
    Parameters
    Type Name Description
    System.Int32 items Number of items to scroll down.
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ScrollLeft(Int32)

    Scrolls the view left.
    Declaration
    public virtual bool ScrollLeft(int cols)
    Parameters
    Type Name Description
    System.Int32 cols Number of columns to scroll left.
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ScrollRight(Int32)

    Scrolls the view right.
    Declaration
    public virtual bool ScrollRight(int cols)
    Parameters
    Type Name Description
    System.Int32 cols Number of columns to scroll right.
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    ScrollUp(Int32)

    Scrolls the view up by items items.
    Declaration
    public virtual bool ScrollUp(int items)
    Parameters
    Type Name Description
    System.Int32 items Number of items to scroll up.
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    SetSource(IList)

    Sets the source of the ListView to an System.Collections.IList.
    Declaration
    public void SetSource(IList source)
    Parameters
    Type Name Description
    System.Collections.IList source
    | Improve this Doc View Source

    SetSourceAsync(IList)

    Sets the source to an System.Collections.IList value asynchronously.
    Declaration
    public Task SetSourceAsync(IList source)
    Parameters
    Type Name Description
    System.Collections.IList source
    Returns
    Type Description
    System.Threading.Tasks.Task An item implementing the IList interface.

    Events

    | Improve this Doc View Source

    OpenSelectedItem

    This event is raised when the user Double Clicks on an item or presses ENTER to open the selected item.
    Declaration
    public event Action<ListViewItemEventArgs> OpenSelectedItem
    Event Type
    Type Description
    System.Action<ListViewItemEventArgs>
    | Improve this Doc View Source

    RowRender

    This event is invoked when this ListView is being drawn before rendering.
    Declaration
    public event Action<ListViewRowEventArgs> RowRender
    Event Type
    Type Description
    System.Action<ListViewRowEventArgs>
    | Improve this Doc View Source

    SelectedItemChanged

    This event is raised when the selected item in the ListView has changed.
    Declaration
    public event Action<ListViewItemEventArgs> SelectedItemChanged
    Event Type
    Type Description
    System.Action<ListViewItemEventArgs>

    Implements

    System.IDisposable
    System.ComponentModel.ISupportInitializeNotification
    System.ComponentModel.ISupportInitialize
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX