How to Improve Scrolling Performance with Down Arrow Key in RadGridView
Environment
Product Version | Product | Author |
---|---|---|
2021.3.914 | RadGridView for WinForms | Desislava Yordanova |
Description
When you press the down arrow key, it is expected to move the current row in RadGridView to the next one. Thus, the style for the new current row should be updated depending on the theme and the old current row's style to be reset. This will move the vertical scrollbar respectively. However, if you keep the down arrow key pressed, this will trigger multiple operations of moving the current row to the next row until you release the down arrow key. RadGridView will try to scroll the view according to the current row and refresh the view. However, when multiple scrolling operations and changing the current row are being executed at the same time, this invalidation is not instant as changing the current row is an expensive operation. This tutorial demonstrates a sample approach how to speed up the scrolling behavior when the down arrow key is kept pressed.
Improved scrolling performance with Down Arrow key
Solution
One possible approach is to use the vertical scrollbar and scroll the view. The TableElement.RowScroller.ScrollMode property gives you different options for scrolling the view. ItemScrollerScrollModes.Deferred is a perfect fit for improving performance as the view is scrolled when you release the thumb. Thus, the current row is not changed in this case and the scrolling is smooth.
Alternatively, with the help of a custom row behavior, you can customize the behavior for the down arrow and change the current row only when you release the down arrow key. While the key is pressed, only scrolling operation is performed. I have prepared a sample code snippet for your reference:
Custom row behavior
Then, apply the behavior: