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

Set Seleceted From Code Behind

1 Answer 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ashrul
Top achievements
Rank 1
Ashrul asked on 11 Jun 2018, 07:04 AM

Hi, i m ashrul

i have problem here, so i have radgridview like this, i have to set selected item on child, in my case last data in is the last selected item automatically from code behind without click.

but i can't handle that.

 

my code like this :

 int a = radTreeListView.Items.TotalItemCount;

 var selectedItem = this.radTreeListView.Items[a-1] as Data;

 

and Data is my property class.

so what i want is, if user add a new data in radgridview so its automatically selected from code behind.

 

thanks in advanced.

 

1 Answer, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 13 Jun 2018, 11:25 AM
Hello Ashrul,

Thank you for the attached picture.

In order to achieve the desired requirement you can set the SelectedItem property of the RadTreeListView like so:
var lastItem = this.RadTreeListView1.Items[this.RadTreeListView1.Items.Count - 1];
 
this.RadTreeListView1.SelectedItem = lastItem;

I am attaching a sample project demonstrating the suggested approach. 

On a side note you can check out the Programmatic Selection article in our documentation.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Ashrul
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or