This question is locked. New answers and comments are not allowed.
When I was using the silverlight DataGrid, I had a following code
this.PricingModelGrid.SelectedIndex = 0;
how however, I'm trying to replace all my datagrid with RadGridView, and I need to know how to change the selected index of a RadGridView from the c# code.
this.PricingModelGrid.SelectedIndex = 0;
how however, I'm trying to replace all my datagrid with RadGridView, and I need to know how to change the selected index of a RadGridView from the c# code.
5 Answers, 1 is accepted
0
Accepted
Hi JungTae,
Something like :
should do the trick.
All the best,
Pavel Pavlov
the Telerik team
Something like :
private void SetSelectedItemByIndex(int index) { this.radGridView1.SelectedItem = this.radGridView1.Items[index]; }should do the trick.
All the best,
Pavel Pavlov
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
0
HDD
Top achievements
Rank 1
answered on 07 Oct 2010, 07:38 PM
Pavel,
This is nice to know. Also I was trying the reverse of this. That is, getting the selected index of the RadGridView.
This is what I have right now:
int selectedindex = radGridView.SelectedItems.IndexOf(radGridView.SelectedItem);
But for some reason I always get 0 (zero) as the value for the selectedindex, which is the first row of the grid.
What could be the cause.
Thanks,
HDD.
This is nice to know. Also I was trying the reverse of this. That is, getting the selected index of the RadGridView.
This is what I have right now:
int selectedindex = radGridView.SelectedItems.IndexOf(radGridView.SelectedItem);
But for some reason I always get 0 (zero) as the value for the selectedindex, which is the first row of the grid.
What could be the cause.
Thanks,
HDD.
0
JungTae
Top achievements
Rank 1
answered on 07 Oct 2010, 07:44 PM
If you are using LINQ, you can use this code. I am currently using it in many places in my code
int index = this.myGrid.Items.IndexOf(this.myGrid.SelectedItem)0
Prakash
Top achievements
Rank 1
answered on 22 Oct 2010, 12:31 PM
I have set the Itemsource to silverlight gird... in the same function i going to select the row by passing the row index.
like
like
this.radGridView1.SelectedItem = this.radGridView1.Items[1];
It says Index out of range, but i have 5 records in the grid.
But when i pass the same on button click it works fine..
could u please help me out..0
Hi Prakash,
Best wishes,
Milan
the Telerik team
I believe you are trying to access the Items before they are actually available. Could you please try to set the SelectedItem in an event handler for DataLoaded.
Best wishes,
Milan
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