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

Getting the Selected Item

8 Answers 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 19 Aug 2008, 09:06 PM
I decided to swap out my WPF ListBox with a radGridView and I can't figure something out.  Currently when I click on an item in my listbox, I grab the ID out of it so I can work with it:

MyCustomObject obj = ((myCustomObject) myListBox.SelectedItem).objectID;

How do I do the same thing with a radGridView?  There is no SelectedItem.  There is a SelectedRecord and CurrentRecord, but I haven't been able to cast those to my custom object.  

Thanks,
Scott

8 Answers, 1 is accepted

Sort by
0
Jimmy
Telerik team
answered on 21 Aug 2008, 02:22 PM
Hello Scott,

To get the CustomObject in the same manner that you do with the WPF ListBox you will have to cast either SelectedRecord or CurrentRecord, depending on your needs, to a DaraRecord Object. The Data property of the DaraRecord Object will return exactly what you are looking for. Following is a short example of how this can be done.

MyCustomObject obj = ((DataRecord)this.radGridView.SelectedRecord).Data as MyCustomObject; 


I hope this works for you.

All the best,
Jimmy
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Scott
Top achievements
Rank 1
answered on 21 Aug 2008, 06:00 PM
Perfect!

What is the equivalent of the ListBox's SelectionChanged event in the radGridView?  I am using MouseUp now to get the ID of the SelectedRecord like you mentioned, but that doesn't work when I switch to using the keyboard.   This seems like such a simple thing, what am I missing?

Thanks much,
Scott
0
Jimmy
Telerik team
answered on 03 Sep 2008, 01:11 PM
Hi Scott,

The bad news is that our official release (the one that you are most probably using) doesn't come with a SelectionChanged event that you could subscribe to.

The good news is that such an event is included in our Service Pack that will be released this Friday, September 5.
By then, you will have to work around this by using other events like the MouseUp or MouseDown to get the job done.

Regards,
Jimmy
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Anton Khramov
Top achievements
Rank 1
answered on 11 Sep 2008, 09:24 AM
Hi, Jimmy!
I cann't find the Service Pack you talk about. Did it releas?

Regards,
Anton.
0
Anton Khramov
Top achievements
Rank 1
answered on 11 Sep 2008, 09:27 AM
Sorry about my engleash.
Was it released?

Regards,
Anton.
0
Pavel Pavlov
Telerik team
answered on 11 Sep 2008, 11:57 AM
Hello Anton,

Thanks for your interest in our products.

Please use the following links to learn more details about our latest release.

http://blogs.telerik.com/HristoDeshev/Posts/08-09-11/RadControls_for_WPF_SP1_is_out.aspx?ReturnURL=%2fBlogs.aspx


You can  get the new distribution from your Client.NET account or play with the online examples at:

http://www.telerik.com/demos/wpf

Greetings,
Pavel Pavlov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Kevin
Top achievements
Rank 1
answered on 20 Apr 2009, 03:24 AM
Hi,

I have the same issue. I have created a DataRecord object but I cant access the data items in it.

You example seems to have disappeared. Can yoiu please reposr the example.

Cheers,
Kevin.
0
Vlad
Telerik team
answered on 21 Apr 2009, 07:22 AM
Hi Kevin,

You can use directly SelectedItem property of RadGridView to access the object.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Scott
Top achievements
Rank 1
Answers by
Jimmy
Telerik team
Scott
Top achievements
Rank 1
Anton Khramov
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Kevin
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or