Skip to content

Table

The Table widget displays data in a tabular format with columns, rows, headers, and selection support.

Table is ideal for displaying structured data like lists of items, records, or any tabular information. It supports keyboard navigation, row selection, and various column types.

The table columns.

foreach (var column in table.Columns)
{
Console.WriteLine(column.Name);
}

The table rows.

foreach (var row in table.Rows)
{
// Access row data
}

An enumerable data source. Setting this automatically rebuilds rows.

table.DataSource = myDataList;

The index of the selected row (-1 if none).

table.SelectedRowIndex = 0;

The currently selected row.

var selected = table.SelectedRow;

Whether to show the header row (default: true).

table.ShowHeader = true;

Whether to show grid lines between columns (default: true).

table.ShowGridLines = true;
  • HeaderForegroundColor: Text color for header
  • HeaderBackgroundColor: Background color for header
  • SelectedRowBackgroundColor: Background for selected row
  • SelectedRowForegroundColor: Text color for selected row
  • GridLineColor: Color of grid lines
  • EmptyStateForegroundColor: Color for empty state message
  • EmptyStateMessage: Message shown when table is empty
  • EmptyStateWidget: Custom widget shown when empty

Adds a column to the table.

var column = new TableColumn("Name", 20);
table.AddColumn(column);

Creates and adds a column.

table.AddColumn("Name", 20);

Adds a row to the table.

var row = table.AddRow(myDataObject);

Removes a row from the table.

table.RemoveRow(row);

Clears all rows.

table.ClearRows();

Refreshes the table, rebuilding rows if DataSource is set.

table.Refresh();

Raised when a row is selected.

table.RowSelected += (row) =>
{
Console.WriteLine($"Selected: {row.Data}");
};

Raised when Enter is pressed on a row.

table.RowActivated += (row) =>
{
// Handle row activation
};
  • Up/Down Arrow: Navigate rows
  • Home: Move to first row
  • End: Move to last row
  • Page Up/Down: Scroll by page
  • Enter: Activate selected row
  • Tab: Navigate to next focusable widget
var table = new Table
{
X = 1,
Y = 1,
Width = 70,
Height = 20,
ShowHeader = true,
ShowGridLines = true
};
table.AddColumn("Name", 30).BindTo<Person>(p => p.Name);
table.AddColumn("Age", 10).BindTo<Person>(p => p.Age);
table.AddColumn("City", 20).BindTo<Person>(p => p.City);
var people = new List<Person>
{
new("Alice", 30, "New York"),
new("Bob", 25, "London")
};
table.DataSource = people;