Each element in the grid can be brought to view using the BringIntoView method. This method will ensure that the grid element is brought into view no matter its state or its parent state. For example, if the grid element is in a collapsed group, the group will be expanded and the grid scrolled (if necessary) so that the grid element is made visible.
The FirstVisibleRow and FirstVisibleColumn properties allow you to change the first/last visible row or column. Setting these properties will automatically bring the newly affected row or column into view.
When setting the CurrentCell, CurrentColumn or CurrentRow properties as well as when calling the MoveCurrentCell, MoveCurrentRow and MoveCurrentColumn methods, the BringIntoView method must be called if you want to bring the new current object into view.
Demonstration
The following examples demonstrates how to bring various grid elements into view. Keep in mind that although the examples mostly use rows located within the grid's DataRows, any other type of row, located in any section of the grid or group (i.e., FixedHeaderRows, FooterRows, etc.) can be brought into view in the same manner.
VB.NET |
Copy Code |
GridControl1.Groups( GridControl1.Groups.Count - 1 ).BringIntoView()
GridControl1.FirstVisibleRow = GridControl1.DataRows( GridControl1.DataRows.Count - 1 ) GridControl1.FirstVisibleColumn = GridControl1.Columns( GridControl1.Columns.Count - 1 )
GridControl1.CurrentCell = GridControl1.DataRows( GridControl1.DataRows.Count - 1 ).Cells( GridControl1.Columns.Count - 1 )
GridControl1.CurrentCell.BringIntoView()
GridControl1.CurrentColumn = GridControl1.Columns( gridControl1.Columns.Count - 1 ) GridControl1.CurrentColumn.BringIntoView()
GridControl1.CurrentRow = GridControl1.DataRows( gridControl1.DataRows.Count - 1 ) GridControl1.CurrentRow.BringIntoView()
|
C# |
Copy Code |
gridControl1.Groups[ gridControl1.Groups.Count - 1 ].BringIntoView();
gridControl1.FirstVisibleRow = gridControl1.DataRows[ gridControl1.DataRows.Count - 1 ]; gridControl1.FirstVisibleColumn = gridControl1.Columns[ gridControl1.Columns.Count - 1 ];
gridControl1.CurrentCell = gridControl1.DataRows[ gridControl1.DataRows.Count - 1 ].Cells[ gridControl1.Columns.Count - 1 ];
gridControl1.CurrentCell.BringIntoView();
gridControl1.CurrentColumn = gridControl1.Columns[ gridControl1.Columns.Count - 1 ]; gridControl1.CurrentColumn.BringIntoView();
gridControl1.CurrentRow = gridControl1.DataRows[ gridControl1.DataRows.Count - 1 ]; gridControl1.CurrentRow.BringIntoView();
|