Automatic Scrolling to SelectedItem

3 posts, 0 answers
  1. GlenC
    GlenC avatar
    12 posts
    Member since:
    May 2009

    Posted 19 Jun 2009 Link to this post

    I have two controls, a RadGridView and RadCoverflow bound to the same ObservableCollection, the former to display the data, the latter to display associated Thumbnail.  When I select the Thumbnail image on the coverflow the appropriate item is also selected on the GridView, however if there is a lot of data and the vertical scrollbars are showing on the GridView, the correct row is selected but I would like the Grid to automatically scroll to that item - is it possible or any sufggestions as to how to implement this?

    Cheers

    Glen
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 19 Jun 2009 Link to this post

    Hello GlenC,

    RadGridView cannot automatically scroll to the selected item but you can easily implement such functionality. Just subscribe to the SelectionChanged event and in the event handler use the BrindDataItemIntoView method to scroll to the selected record/item.

    Here is a sample snippet:

    public Page()  
    {  
        InitializeComponent();  
     
        this.data = GetMessages();  
        this.RadGridView1.ItemsSource = this.data;  
        this.RadGridView1.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(RadGridView1_SelectionChanged);  
    }  
     
    void RadGridView1_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)  
    {  
        this.RadGridView1.ItemsControl.BringDataItemIntoView(this.RadGridView1.SelectedItem);  


    Kind regards,
    Milan
    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.
  3. DevCraft banner
  4. GlenC
    GlenC avatar
    12 posts
    Member since:
    May 2009

    Posted 19 Jun 2009 Link to this post

    Thanks Milan,

    very quick reply and it works for me

    CHeers

    Glen
Back to Top