Hello,
Thank you for writing.
Basically, you would need to calculate a scroll offset and set it as a value of the scroll bar and if needed perform a selection of the row. In my example below, I am performing a page down logic in the
Click event of
RadButton. Similarly, you can navigate upwards:
private
void
radButton1_Click(
object
sender, EventArgs e)
{
int
scrollDelta =
this
.radGridView1.TableElement.ViewElement.ScrollableRows.Size.Height + (
int
)
this
.radGridView1.TableElement.ViewElement.ScrollableRows.ScrollOffset.Height;
int
newVScrollValue =
this
.radGridView1.TableElement.VScrollBar.Value + scrollDelta;
if
(newVScrollValue <
this
.radGridView1.TableElement.VScrollBar.Maximum -
this
.radGridView1.TableElement.VScrollBar.LargeChange)
{
this
.radGridView1.TableElement.VScrollBar.Value = newVScrollValue;
}
else
{
this
.radGridView1.TableElement.VScrollBar.Value =
this
.radGridView1.TableElement.VScrollBar.Maximum -
this
.radGridView1.TableElement.VScrollBar.LargeChange;
}
IGridNavigator navigator =
this
.radGridView1.GridViewElement.Navigator;
navigator.BeginSelection(
new
GridNavigationContext(GridNavigationInputType.Keyboard, MouseButtons.None, Keys.None));
navigator.SelectRow(
this
.GetLastScrollableRow(
this
.radGridView1.TableElement));
navigator.EndSelection();
}
private
GridViewRowInfo GetLastScrollableRow(GridTableElement tableElement)
{
ScrollableRowsContainerElement rows = tableElement.ViewElement.ScrollableRows;
GridTraverser traverser = (GridTraverser)((IEnumerable)tableElement.RowScroller).GetEnumerator();
for
(
int
i = 0; i < rows.Children.Count; i++)
{
if
(rows.Children[i].BoundingRectangle.Bottom > rows.Size.Height)
{
break
;
}
if
(!traverser.MoveNext())
{
break
;
}
}
return
traverser.Current;
}
I hope this helps. Should you have further questions please do not hesitate to write back.
Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this
blog post and share your thoughts.