ColumnView.MoveFirst() Method
Moves focus to the first row.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v18.2.dll
Declaration
Remarks
If the first row is invisible on screen, call the MoveFirst method to scroll the View back to the top.
Users can press the “First” button of the embedded data navigator, or press the CTRL+HOME combination while the View has focus, to return to the grid’s top.
Note
Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the MoveFirst member must not be invoked for these Views. The MoveFirst member can only be used with real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.
- GridControl.MainView - returns the top most View in a grid;
- GridControl.FocusedView - returns the focused View;
- GridControl.DefaultView - returns the currently maximized View;
- the sender parameter of View specific events;
- GridView.GetDetailView - returns a detail clone View for a specific master row.
The code sample below illustrates how to scroll to the grid’s top when users click a button.
gridView1.TopRowChanged += GridView1_TopRowChanged;
BackToTopButton.Click += BackToTopButton_Click;
private void GridView1_TopRowChanged(object sender, EventArgs e)
{
BackToTopButton.Enabled = (gridView1.TopRowIndex == 0) ? false : true;
}
private void BackToTopButton_Click(object sender, EventArgs e)
{
gridView1.MoveFirst();
}