Disable Horizontal ScrollBar

11 posts, 1 answers
  1. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 06 Aug 2008 Link to this post

    Is it possible to disable the horizontal scrolling on the RadTreeView?

    am using the tree control to create Gantt View with a table and chart.  I want to handle horizontal scrolling myself so that I can scroll the two side seperately.  I have created controls for the row in the view that are split and have their own ScrollViewers that I control programatically but the treeview is adding it's own horizontal scrollbar when the content exceeds the width of the page.

    I have tried setting the static properties ScrollViewer properties but this throws an exception

    ScrollViewer.HorizontalScrollBarVisibility

    ="Disabled"

    ScrollViewer.VerticalScrollBarVisibility="Disabled"

    Is there another way to do it?

    Mike
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 06 Aug 2008 Link to this post

    Hi Mike,

    For the moment you can not do it from the XAML, but you can use the ScrollViewer property of RadTreeView and to configure it. Let me know how it goes.

    Sincerely yours,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 06 Aug 2008 Link to this post

    Tried that in the Loaded event of the UserControl and in the Loaded event of the TreeView but in both cases I get a NullReferenceException when accessing the ScrollViewer property.

    Any suggestions?
  5. Answer
    Valio
    Valio avatar
    102 posts
    Member since:
    Jun 2006

    Posted 06 Aug 2008 Link to this post

    Hello Mike,

    The ScrollViewer property is initialized once the template for the TreeView has been applied. You can use the following code as a reference:

        public partial class FirstLook : UserControl  
        {  
            public FirstLook()  
            {  
                InitializeComponent();  
                RadTreeView1.ItemContainerGenerator.StatusChanged += new EventHandler(ItemContainerGenerator_StatusChanged);     
            }  
     
            void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)  
            {  
                if (RadTreeView1.ItemContainerGenerator.Status == Telerik.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)  
                {  
                    if (RadTreeView1.ScrollViewer != null)  
                    {  
                        RadTreeView1.ScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;  
                    }  
                }  
            }  
        } 

    Best Regards,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 07 Aug 2008 Link to this post

    That worked perfectly to hide the scrollbar of the TreeView, thanks.

    At first I thought this was what is needed but although the scrollbar is hidden or disabled (as set) but it still allows the contents to stretch to a width that means  my own ViewScrollers are never activated so not quite what I need.

    Will let you know if I get any further.
  7. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 07 Aug 2008 Link to this post

    Hello Mike,

    I'm not sure what real situation is, but let us know if we can help you in this scenario.

    Greetings,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 07 Aug 2008 Link to this post

    I guess what I am looking for is a way to make the RadTreeView take up the whole width of the area it is given (in my case the whole width of the browser).  However when an item is wider than the width of the browser, I don't want the treeview to use it's scrollbars because the items have their own.

    I can't share the code I am working on here, but I could post it with a support ticket if it helps

    Mike
  9. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 07 Aug 2008 Link to this post

    Hello Mike,

    Maybe in this case you better change the control template of the RadTreeView and remove the ScrollViewer at all?

    Greetings,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  10. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 07 Aug 2008 Link to this post

    Unfortunately that is not an option.  The control used for the template is a GanttRow which is split with a table on the left side and a graph on the right side.

    What I am trying to achieve (in a quick and dirty fashion because of time scales) is create a split view.  Each GanttRow has two scroll viewers one around the table and one around the graph, in a containing GanttView I have managed to synchronise horizontal scrolling of the table part, but cannot do so with the right side because the scrollviewer around it never activates because the treeview is making as much space as it needs available.

    I am just about to try programattically setting a fixed width on each GanttRow that is less than the page width.

    I did say it was quick and dirty?
  11. Mike Hanson
    Mike Hanson avatar
    25 posts
    Member since:
    Jul 2005

    Posted 07 Aug 2008 Link to this post

    Solved the problem with code:-)

    In the SizeChanged event of the outer control I iterate through all the GanttRow items and set them to the width of the RadTreeView minus the width of the Expander.  This then deactivates the ScrollViewer of the RadTreeView and lets the GanttRow handle it's own scrolling.

    Thanks for all your help

    Mike
  12. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 07 Aug 2008 Link to this post

    Hi Mike,

    I'm glad you were able to achieve the scenario - I was just wondering what else to propose as a solution :)

    Best wishes,
    Valentin.Stoychev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
DevCraft banner