In our validation forms, we like to preselect the currently choosen item. I have the code written for selecting the corresponding BindingSource.Position. This automatically selects the row. How can I force the GridView to scroll to the currently selected row?
Thanks,
Travis
7 Answers, 1 is accepted
You can scroll to the concrete row by invoking the GridTableElement's method SrollToRow. You can use the following code snippet to achieve that:
GridTableElement tableElement =
this
.radGridView.CurrentView
as
GridTableElement;
GridViewRowInfo row =
this
.radGridView.CurrentRow;
if
(tableElement !=
null
&& row !=
null
)
{
tableElement.ScrollToRow(row);
}
Kind regards,
Svett
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Thank you for writing.
As long as the grid is data bound and the actual data is loaded you can use the method proposed by my colleague. When bound RadGridView creates its own data items based on the data source and uses them for navigation.
I hope this will be useful. Should you have further questions, I would be glad to help.
Regards,
Ivan Petrov
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Thank you.
This is my code :
private void radGVToBeApproved_SelectionChanged(object sender, EventArgs e){this.radGVToBeApproved.SummaryRowsTop.Clear();this.radGVToBeApproved.SummaryRowsBottom.Clear();GridViewSummaryItem summaryItemCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, "Total rows : {0}", GridAggregateFunction.Count);GridViewSummaryItem summaryItemSelectedRowsCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, " Total selected rows : {0}", radGVToBeApproved.SelectedRows.Count.ToString());GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(new GridViewSummaryItem[] { summaryItemCount, summaryItemSelectedRowsCount });this.radGVToBeApproved.SummaryRowsTop.Add(summaryRowItem);this.radGVToBeApproved.SummaryRowsBottom.Add(summaryRowItem);}
Hello everybody,
I need your help,My problem is when i select many rows in radGridView (Telerik) and specialy when i select rows in the bottom of the RadGridView. the sroll move to the top. I need to fix the scroll position to be in the same position of the last selected row.
Thank you.
This is my code :
private void radGVToBeApproved_SelectionChanged(object sender, EventArgs e)
{
this.radGVToBeApproved.SummaryRowsTop.Clear();
this.radGVToBeApproved.SummaryRowsBottom.Clear();
GridViewSummaryItem summaryItemCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, "Total rows : {0}", GridAggregateFunction.Count);
GridViewSummaryItem summaryItemSelectedRowsCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, " Total selected rows : {0}", radGVToBeApproved.SelectedRows.Count.ToString());
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(
new GridViewSummaryItem[] { summaryItemCount, summaryItemSelectedRowsCount });
this.radGVToBeApproved.SummaryRowsTop.Add(summaryRowItem);
this.radGVToBeApproved.SummaryRowsBottom.Add(summaryRowItem);
}
Hello Imane,
According to the provided code snippet, it seems that you clear the SummaryRowsTop/SummaryRowsBottom collections in the SelectionChanged event. Note that this causes updating the view of the grid and this is why the vertical scrollbar is reset to its default position. I can suggest you to store the vertical scrollbar value before performing a clear operation and the restore it after that:
private void RadGridView1_SelectionChanged(object sender, EventArgs e)
{
int scrollValue = radGridView1.TableElement.VScrollBar.Value;
this.radGridView1.SummaryRowsTop.Clear();
this.radGridView1.SummaryRowsBottom.Clear();
radGridView1.TableElement.VScrollBar.Value = scrollValue;
//...
}
I hope this helps. Do not hesitate to contact me if you have other questions.
Regards,
Nadya
Progress Telerik