Class ListView
ListView widget renders a list of data.
Inherited Members
Namespace: Terminal.Gui
Assembly: Terminal.Gui.dll
Syntax
public class ListView : Terminal.Gui.View
Remarks
The ListView displays lists of data and allows the user to scroll through the data
and optionally mark elements of the list (controlled by the AllowsMark property).
The ListView can either render an arbitrary IList object (for example, arrays, List
The ListView can display any object that implements the System.Collection.IList interface,
string values are converted into ustring values before rendering, and other values are
converted into ustrings by calling ToString() and then converting to ustring.
If you must change the contents of the ListView, set the Source property (when you are
providing your own rendering via the IListDataSource implementation) or call SetSource
when you are providing an IList.
Constructors
ListView(IList)
Initializes a new ListView that will display the contents of the object implementing the IList interface, with relative positioning
Declaration
public ListView (System.Collections.IList source);
Parameters
| Type | Name | Description |
|---|---|---|
| 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. |
ListView(IListDataSource)
Initializes a new ListView that will display the provided data source, uses relative positioning.
Declaration
public ListView (Terminal.Gui.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. |
ListView(Rect, IList)
Initializes a new ListView that will display the contents of the object implementing the IList interface with an absolute position.
Declaration
public ListView (Terminal.Gui.Rect rect, System.Collections.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. |
ListView(Rect, IListDataSource)
Initializes a new ListView that will display the provided data source with an absolute position
Declaration
public ListView (Terminal.Gui.Rect rect, Terminal.Gui.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
AllowsMarking
Gets or sets a value indicating whether this ListView allows items to be marked.
Declaration
public bool AllowsMarking { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
SelectedItem
Gets or sets the currently selecteded item.
Declaration
public int SelectedItem { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | The selected item. |
Source
Gets or sets the IListDataSource backing this view, use SetSource() if you want to set a new IList source.
Declaration
public Terminal.Gui.IListDataSource Source { get; set; }
Property Value
| Type | Description |
|---|---|
| IListDataSource | The 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
MouseEvent(MouseEvent)
Declaration
public override bool MouseEvent (Terminal.Gui.MouseEvent me);
Parameters
| Type | Name | Description |
|---|---|---|
| MouseEvent | me | To be added. |
Returns
| Type | Description |
|---|---|
| System.Boolean | To be added. |
PositionCursor()
Positions the cursor in this view
Declaration
public override void PositionCursor ();
ProcessKey(KeyEvent)
Handles cursor movement for this view, passes all other events.
Declaration
public override bool ProcessKey (Terminal.Gui.KeyEvent kb);
Parameters
| Type | Name | Description |
|---|---|---|
| KeyEvent | kb | Keyboard event. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
Redraw(Rect)
Redraws the ListView
Declaration
public override void Redraw (Terminal.Gui.Rect region);
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | region | Region. |
SetSource(IList)
Sets the source to an IList value, if you want to set a full IListDataSource, use the Source property.
Declaration
public void SetSource (System.Collections.IList source);
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.IList | source | To be added. |
Events
SelectedChanged
This event is raised when the cursor selection has changed.
Declaration
public event Action SelectedChanged;
Event Type
| Type | Description |
|---|---|
| System.Action | To be added. |