Home Forums WinForms controls Xceed Grid for WinForms FirstVisibleRow Reply To: FirstVisibleRow

User (Old forums)
Post count: 23064

What you could try: check to see if the FirstVisibleRow is a GroupManagerRow. If it is, get the ParentGroup, get the first DataRow from that group (through the GetSortedDataRows-method), and keep the index of that row. When refreshing, find that row, get the ParentGroup, and set the FirstVisibleRow of the grid to the first row in the HeaderRows of that group.

Before the refresh:
Dim topRowIsGMR As Boolean
Dim topRow As Xceed.Grid.Row = Me.grdOrders.FirstVisibleRow
Dim topRowIndex As Int32

If topRow Is Xceed.Grid.GroupManagerRow Then
topRowIsGMR = True
topRowIndex = Me.grdOrders.DataRows.IndexOf(topRow.ParentGroup.GetSortedDataRows().Item(0))
topRowIsGMR = False
topRowIndex = Me.grdOrders.DataRows.IndexOf(topRow)
End If

After the refresh:
If topRowIsGMR Then
Me.grdOrders.FirstVisibleRow = Me.grdOrders.DataRows.Item(topRowIndex).ParentGroup.HeaderRows.Item(0)
Me.grdOrders.FirstVisibleRow = Me.grdOrders.DataRows.Item(topRowIndex)
End If

PS: this code has not been tested, and might not be valid VB.NET (I’m a C# programmer)

Imported from legacy forums. Posted by Tommy (had 3202 views)