This is a migrated thread and some comments may be shown as answers.

Dock host window Scrollbars

7 Answers 203 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Satyajeet B
Top achievements
Rank 1
Satyajeet B asked on 21 Sep 2009, 08:32 AM
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



 

7 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 24 Sep 2009, 08:35 AM
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.
0
Satyajeet B
Top achievements
Rank 1
answered on 25 Sep 2009, 06:24 AM
thanks Nikolay .........  it works fine.
0
Denis Cilliers
Top achievements
Rank 1
answered on 02 Nov 2012, 11:29 AM
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
0
Nikolay
Telerik team
answered on 06 Nov 2012, 03:10 PM
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.
0
Denis Cilliers
Top achievements
Rank 1
answered on 07 Nov 2012, 09:41 AM
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?
0
Nikolay
Telerik team
answered on 08 Nov 2012, 12:23 PM
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.
0
Denis Cilliers
Top achievements
Rank 1
answered on 09 Nov 2012, 11:56 AM
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
Tags
Dock
Asked by
Satyajeet B
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Satyajeet B
Top achievements
Rank 1
Denis Cilliers
Top achievements
Rank 1
Share this question
or