My app is a slow 'scrolling' list of rows. New rows get added to the datasource periodically and I use AutoFocusNewRow to
automatically snap the added row into view when the row is added. I also let the user turn this off via a context menu,
but I notice the grid then automatically snaps to the _selected_ row, is there any way to turn this off? I really just want the
grid to keep its current scroll position when AutoFocusNewRow=false.
Thanks
Matt
GridView - How to avoid auto focusing a partially visible row
Answers
Hi James,
When the datasource is changed, row handles are regenerated and the grid tries to focus the previously focused row. When the row is focused the grid makes it visible. This behavior is by design.
You can change it by creating a custom GridView in a GridControl descendant and overriding the GridView.MakeRowVisibleCore method and disabling its functionality.
I have modified your project accordingly. It is attached.
Please let us know if this makes sense.
Thanks,
Michael.
I am happy to hear that my assistance was helpful to you. Please do not hesitate to contact us if you experience problems when using our products.
Hi Matt,
Sorry, it is unclear how you setup the grid and which behavior you want to disable. If it operates in singleselect mode, the selected row is hardwired to the focused one. Please explain your task in detail. A sample project would be helpful too.
Thanks,
Michael.
I'll try come up with a simple example…
Perhaps I can explain better in the mean time. I have a grid, sorted by date, and I add rows to the bindinglist via code periodically. These rows appear (because of the sort) at the top of the grid. I want the new row to be automatically scrolled into view when it is added (AutoFocusNewRow=true seems to do this), and also want to give the user the chance to turn this off so his scroll position is maintained when a row is added. Though when I set AutoFocusNew row to false, the grid seems to auto scroll to the selected/focused row when a row is added, I cant seem to stop this from
happening. I do _not_ add rows through the grid UI, it is all backend via the bindinglist…
Thanks
Matthew
Hi James,
Sorry, we cannot reproduce this issue. I have prepared an example for you which works fine. It is attached. Please modify it to reproduce the issue and post here for analysis.
Thanks,
Michael.
Michael, I've come up with an example to show the problem, and I think I've figured out why you're not seeing it…
We're sorting a column so that new rows get added to the top.
Run the attached sample and sort on one of the columns, so that new rows appear above (click the col header twice). I've created a column context menu called 'Snap To new Row' … The snapping to new row works perfectly, but when its off, try scroll anywhere, you will see the grid 'snap' back to the selected row, I dont want this, I want to keep my scroll position when a new row is added. Hope this finally shows the issue we are having.
Please also take note of the version of VStudio and DevX we are using, your last example was compiled on VS2005 and
we couldnt use it.
Thanks
Matthew