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
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
0
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.
I hope this works for you.
All the best,
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
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
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
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,
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
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.
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.
Was it released?
Regards,
Anton.
0
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.
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.
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
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.
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.