Dock host window Scrollbars

8 posts, 1 answers
  1. Satyajeet B
    Satyajeet B avatar
    11 posts
    Member since:
    Aug 2009

    Posted 21 Sep 2009 Link to this post

    Hi there,

    I am opening an already existing form in a dock host window.  
    How can i add Horizontal and Vertical scroll bars to new document host window.
    FYI i have tried with the belwo code, but doesnt work.

    Dim

     

    objForm As New Form

     

     

    Dim hostWindow As HostWindow = RadDock1.DockControl(objForm , DockPosition.Right)

     

    RadDock1.AddDocument((hostWindow), DockPosition.Fill)

     

    'hostWindow.AutoScroll = True

     

    hostWindow.HorizontalScroll.Enabled =

    True

     

    hostWindow.VerticalScroll.Enabled =

    True


    Thanks,
    Satyajeet



     

  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 24 Sep 2009 Link to this post

    Hello Satyajeet B,

    When you dock a form in a HostWindow this form gets its Dock property set to Fill. Please note that in .NET Windows Forms you cannot get the scrollbars of the container if its child control is Docked into it. So, if you want to get the scrollbars of the HostWindow, you first need to set the Dock property of the form to None and then set the AutoScroll property of the HostWindow to true.

    If you have additional questions, feel free to contact me.

    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. Satyajeet B
    Satyajeet B avatar
    11 posts
    Member since:
    Aug 2009

    Posted 25 Sep 2009 Link to this post

    thanks Nikolay .........  it works fine.
  5. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 02 Nov 2012 Link to this post

    Sry to bring this back up, how would you do this in code

    My calling code looks like this atm, I loads the forms into the Dock no problem, but still no scrollbars

     
    Shared Sub dockForm(ByVal myform As Form)
     
           For Each currentdoc As DockWindow In frmMain.radDockMain.DockWindows
               If currentdoc.Controls.Count > 0 And currentdoc.Controls(0).Text.Equals(myform.Text) Then
     
                   frmMain.radDockMain.ActiveWindow = currentdoc
                   Exit Sub
               End If
           Next
     
           With myform
               .FormBorderStyle = FormBorderStyle.None
               .Dock = DockStyle.None
               .TopLevel = False
               '.AutoScroll = True
           End With
     
           'Create a new host 
           Dim hostWindow As HostWindow = frmMain.radDockMain.DockControl(myform, DockPosition.Right)
     
           'Add the form Title to the document
           hostWindow.Text = myform.Text
     
           'add to Dock
           frmMain.radDockMain.AddDocument(hostWindow, DockPosition.Fill)
     
           'Set the ScrollBars
           hostWindow.HorizontalScroll.Enabled = True
           hostWindow.VerticalScroll.Enabled = True
     
           'Set Active
           frmMain.radDockMain.ActiveWindow = hostWindow
     
           If Not myform.IsDisposed Then
               myform.Show()
           End If
     
       End Sub
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 06 Nov 2012 Link to this post

    Hello Denis,

    In order to get scrollbars that match the size of the form, you should set the MinimumSize and MaximumSize properties of the form in addition to the Size property. Last, but not least, in order to enable the scrollbars of the HostWindow now you just need to set the AutoScroll property to true. I am attaching a sample project that demonstrates the approach.

    I hope this helps. Let me know if you have additional questions. 

    Greetings,
    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.
  7. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 07 Nov 2012 Link to this post

    Hmm one issue with the code you sent

    changing the setting from Fill to Top changes the way the Dock works 

    'add to Dock
           frmMain.radDockMain.AddDocument(hostWindow, DockPosition.Fill)
    'To
           frmMain.radDockMain.AddDocument(hostWindow, DockPosition.Top)

    Top  - Will allow the scroll bars to appear, but on enlarging the window the form size becomes apparent.  
    Thus if your form is too large for the size of the screen it works fine, but for smaller forms it does not

    I would have to check the current size of the dock at adding time, as this Fill option seems to be the issue.
    As docking the form using top will add the form and setup the bars, but not use the full space
    Using Fill will use the full space, but chop off the forms that are larger, and not show scroll bars.

    What you realy want is something in the middle. To use the full space, and to have the scroll bars

    Maybe we can set the background of the dock to the same colour as the form?
  8. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 08 Nov 2012 Link to this post

    Hello Denis,

    Indeed, the best solution for this scenario would be to set the background color of the window that contains your form. This way it will not be apparent where the form ends. To do so, just set the BackColor of the HostWindow like so:

    hostWindow.BackColor = Color.Green

    Let me know if you have additional questions.Kind regards,
    Nikolay
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 09 Nov 2012 Link to this post

    Yep that works 
    the current version I added to the function is 

    hostWindow.BackColor = myform.BackColor

    This makes the two of them the same, and the user would thus think it is one form.

    We loose the fill function, but I might just make that a setting for those forms that would use the full space

    Thanks again
Back to Top
UI for WinForms is Visual Studio 2017 Ready