RadDock - Dynamically adding UserControls with autoscroll

3 posts, 0 answers
  1. Pawz
    Pawz avatar
    51 posts
    Member since:
    Aug 2007

    Posted 10 Sep 2009 Link to this post

    How do I get this to work? I'm dynamically adding a UserControl to the Dock control, and I can't seem to get the docked window to get scrollbars to show up when it is resized.

    CSUserControl itemControl; 
     
                if (typeof(CSUserControl).IsAssignableFrom(ucType)) 
                { 
                    itemControl = (CSUserControl) Activator.CreateInstance(ucType, parameterList); 
                } 
                else 
                { 
                    UserControl item = (UserControl)Activator.CreateInstance(ucType, parameterList); 
                     
                    itemControl = new CSUserControl(); 
                    itemControl.Controls.Add(item); 
                    item.Dock = DockStyle.Fill; 
                } 
     
                Size size = itemControl.Size; 
                //Hook up events 
                itemControl.WindowChangeRequested += documentPane_WindowChangeRequested; 
                itemControl.WindowOpenRequested += documentPane_WindowOpenRequested; 
                itemControl.WindowCloseRequested += documentPane_WindowCloseRequested; 
     
                itemControl.AutoScroll = true
     
                HostWindow host; 
                if (dockPosition == DockPosition.Fill) 
                { 
                    host = _dock.DockControl(itemControl, dockPosition, DockType.Document); 
                } 
                else 
                { 
                    host = _dock.DockControl(itemControl, dockPosition); 
                } 
     
                
                host.Text = documentName; 
                host.Name = documentName; 
                host.CloseAction = DockWindowCloseAction.CloseAndDispose; 
                host.AutoScroll = true
                host.TabStrip.AutoScroll = true
                //host.TabStrip.MinimumSize = itemControl.MinimumSize; 
                //host.MinimumSize = itemControl.MinimumSize; 
     
                DockTabStrip strip = (DockTabStrip)host.TabStrip; 
                strip.SizeInfo.AbsoluteSize = size; 
                _dock.ActivateWindow(host); 

    CSUserControl is simply a wrapper around the standard UserControl that gives me some extra functionality.

    I've gotten it SORT OF working by using the commented out lines above - when I set the TabStrip AutoScroll  = true and the minimum size as well, then the scrollbars show up. BUT it's terrible in implementation - the tabstrip randomly disappears or repeats itself, scrollbars show up when they're not supposed to be, scrolling around wrecks the tabstrib.

    How am I supposed to be doing this?
  2. Nikolay
    Admin
    Nikolay avatar
    1804 posts

    Posted 17 Sep 2009 Link to this post

    Hello Pawz,

    Please find the answer to your question in the support ticket regarding the same topic: Using Autoscroll with Docking windows.

    Kind regards,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 21 Oct 2009 Link to this post

    Hi,

    Besides setting the Form Autoscroll property to true, you also need to set the AutoScrollMinSize to the size that you want the scroll bars to appear.
Back to Top