Skip to main content

Table and TreeList View Scrolling in Code

  • 2 minutes to read
Horizontal Scrolling

A horizontal scroll bar is automatically displayed if the automatic column width calculation is disabled (the TableView.AutoWidth property is set to false) and the total width of columns exceeds the grid’s width. In this instance, you can use the GridViewBase.FocusedColumn property or DataViewBase.MoveNextCell/DataViewBase.MovePrevCell method to horizontally scroll the grid’s contents in code to make the entire column visible onscreen.

If the TableView.AutoWidth property is set to false and the number of columns is large, you can speed up the grid’s performance by enabling the TableView.AllowHorizontalScrollingVirtualization option. If this option is enabled, the grid renders only those columns that are displayed onscreen. Each time a View is horizontally scrolled, visible columns (displayed onscreen) are rendered again. Otherwise, if the TableView.AllowHorizontalScrollingVirtualization property is set to false, the grid renders all columns.

Vertical Scrolling

A vertical scroll bar is automatically displayed if a View cannot display all rows (nodes in a TreeListView). To make the specified row visible onscreen in code, use the DataViewBase.ScrollIntoView method:

// Scroll to the first row:
gridControl1.View.ScrollIntoView(gridControl1.GetRowHandleByVisibleIndex(0));
// Scroll to the last row:
gridControl1.View.ScrollIntoView(gridControl1.GetRowHandleByVisibleIndex(gridControl1.VisibleRowCount - 1));

To make the specified row visible and focus it, use the DataViewBase.FocusedRowHandle property or DataViewBase.MoveFocusedRow method. To learn more, see Moving Row Focus.

See Also