Can't get to previous visible row after a data refresh
I have a datagrid that I refresh after a save to make sure I have current valid data. Before I start to refresh the underlying datatable, I get (what I think is) the top body line index:
Dim visibleRows = sdg_LEDGER.TableControl.ScrollRows.GetVisibleLines For Each line In visibleRows If line.Region = ScrollAxisRegion.Body Then topBodyLineIndex = line.LineIndex Exit For End If Next
Then I create a new datatable, and set it to the datagrid:
sdg_LEDGER.DataSource = Nothing sdg_LEDGER.DataSource = dt
After getting some totals (the grid is used for a general ledger), I then try to set the top line again to what it was before, so the user doesn't have to scroll through the grid to get back where they were by this:
sdg_LEDGER.TableControl.ScrollRows.ScrollInView(topBodyLineIndex) sdg_LEDGER.TableControl.UpdateScrollBars()
Now, the grid does change scroll position, but it does not bring the index I set into view. In fact, it's several (10 or so) rows below the bottom of the visible grid.
Am I missing something here or should this work?
|
Attachment: SfDataGridDemo_8e07c1e7.zip
My grid had two summary rows. One at top, one at the bottom. Your code example did not work at first, but when I removed the summary row at the top, it works. I don't need the summary row at the top, so I simply removed it.
Thanks.
- 3 Replies
- 2 Participants
-
GS Gary Smith
- May 26, 2026 07:50 AM UTC
- May 29, 2026 09:02 AM UTC