This is a migrated thread and some comments may be shown as answers.

How to Select a row by index?

3 Answers 379 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kennet
Top achievements
Rank 2
Kennet asked on 27 Nov 2009, 10:29 PM
Lets say I have 100 rows, I want to select row number 10, how do I do that and also scroll the selected row into view.

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 29 Nov 2009, 08:23 AM
Hi Kennet,

You could use the following code to achieve the desired result:

this.myGrid.SelectedItem = this.myGrid.Items[10];
this.myGrid.ScrollIntoView(this.myGrid.SelectedItem);


Sincerely yours,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kennet
Top achievements
Rank 2
answered on 30 Nov 2009, 07:53 AM
Hi Milan,

That works fine, but selectintoview show the selected row as last row. What if I want it as second from top or in the middle, even if I resize my window so the hiegt of the grid changes.

0
Accepted
Milan
Telerik team
answered on 03 Dec 2009, 02:05 PM

Hello Kennet,

For the time being it is not possible to adjust the behavior of the ScrollIntoView method. If you would like to keep a specifies item visible at all times (even if RadGridView is resized) you can subscribe to the SizeChanged event and call ScrollIntoView every time this event is raised.


Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Kennet
Top achievements
Rank 2
Answers by
Milan
Telerik team
Kennet
Top achievements
Rank 2
Share this question
or