Any way to scroll to a tab that is hidden from the scroll area?

5 posts, 0 answers
  1. joseph_korn
    joseph_korn avatar
    21 posts
    Member since:
    Apr 2007

    Posted 21 Aug 2008 Link to this post

    I have a tab strip control that has a dynamic amount of tabs.  Autoscroll is set to true so that if there is more tabs then there is space to show all tabs, I can scroll back and forth to find the tab I need. The user is also given the ability to add new tabs as is necessary.  When a new tab is created by the user, I want to make it the currently selected tab, and bring focus to the first control on that tab page. I have been able to successfully select the new tab by using tabstrip.SelectedTab = tabstrip.Items(tabstrip.Items.Count - 1).  The problem I have is that sometimes the new tab is way off on the right side, and is hidden from sight because there are too many tabs. Is there some kind of function like ScrollToTab() or some way that I can programatically scroll to that last tab so that I can see it if it is off the screen?
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 22 Aug 2008 Link to this post

    Hi Joseph,

    Thank you for writing.

    You should select the desired tab using the RadTabStrip.TabStripElement.ScrollIntoView function.
    For example:
    //scroll to last item
      tabstrip.TabStripElement.ScrollIntoView( ((TabItem)this.tabstrip.Items[tabstrip.Items.Count - 1]) );

    //focus the last item
     
    ((TabItem) this.tabstrip.Items[tabstrip.Items.Count - 1]).IsSelected = true;

    Hope this helps.

    Regards,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. joseph_korn
    joseph_korn avatar
    21 posts
    Member since:
    Apr 2007

    Posted 22 Aug 2008 Link to this post

    Thank you for the reply.

    I have tried the code below and unfortunately it does not seem to work for me.  However, it is very possible that the issue is still on my end as I am currently reworking my project. The 'ScrollIntoView' function you suggested sounds exactly what I had in mind.  After making some necessary adjustments, I will let you know if I continue to experience problems with this feature.
  5. Dan
    Dan avatar
    6 posts
    Member since:
    Jul 2008

    Posted 15 Nov 2008 Link to this post

    Is there a VB version of this?
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 18 Nov 2008 Link to this post

    Hi Dan,

    Here is the VB.NET version of the code snippet:
    Me.RadTabStrip1.TabStripElement.ScrollIntoView(CType(Me.RadTabStrip1.Items(Me.RadTabStrip1.Items.Count - 1), TabItem))  
    CType(Me.RadTabStrip1.Items(Me.RadTabStrip1.Items.Count - 1), TabItem).IsSelected = True 

    Regards,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for WinForms is Visual Studio 2017 Ready