Getting the Selected Item

9 posts, 0 answers
  1. Scott
    Scott avatar
    43 posts
    Member since:
    Nov 2007

    Posted 19 Aug 2008 Link to this post

    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
  2. Jimmy
    Admin
    Jimmy avatar
    16 posts

    Posted 21 Aug 2008 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Scott
    Scott avatar
    43 posts
    Member since:
    Nov 2007

    Posted 21 Aug 2008 Link to this post

    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
  5. Jimmy
    Admin
    Jimmy avatar
    16 posts

    Posted 03 Sep 2008 Link to this post

    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.
  6. Anton Khramov
    Anton Khramov avatar
    15 posts
    Member since:
    Sep 2008

    Posted 11 Sep 2008 Link to this post

    Hi, Jimmy!
    I cann't find the Service Pack you talk about. Did it releas?

    Regards,
    Anton.
  7. Anton Khramov
    Anton Khramov avatar
    15 posts
    Member since:
    Sep 2008

    Posted 11 Sep 2008 Link to this post

    Sorry about my engleash.
    Was it released?

    Regards,
    Anton.
  8. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 11 Sep 2008 Link to this post

    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.
  9. Kevin
    Kevin avatar
    26 posts
    Member since:
    Apr 2009

    Posted 19 Apr 2009 Link to this post

    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.
  10. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 Apr 2009 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready