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

Open several winforms on dock

1 Answer 213 Views
Dock
This is a migrated thread and some comments may be shown as answers.
R.H.B. Haukes
Top achievements
Rank 1
R.H.B. Haukes asked on 26 May 2010, 09:55 AM
Hi there,

I'm pretty new with Telerik and have a question. I have a RadDock1 on a form. On that form there is also a button. Every time the users clicks this button I want to create a new tab on RadDock1 filled (maximized) with a (win)Form (named "frmProject").
I've created a sub "AddPage":

    Private Sub RadButtonElement1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles RadButtonElement1.Click  
        AddPage(frmProject, "Project")  
    End Sub 
 
 
    Private Sub AddPage(ByVal f As Form, ByVal strPage As String)  
 
        RadDock1.DockControl(f, DockPosition.Fill, DockType.Document)  
 
    End Sub 

The first time the user clicks the button a new tab is added with the form filled on it. But the second time the user clicks the button only a tab is added. I can't see the form.

Can you please tell me what I am doing wrong?

Kind regards,
Ronald

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 28 May 2010, 02:04 PM
Hi R.H.B. Haukes,

Thank you for the questions.

In order to set custom text to the TabItem of the HostWindow that hosts your form, you can use the following pattern:
Private Sub AddPage(ByVal f As Form, ByVal strPage As String)
    Dim hostW As HostWindow = Me.radDock1.DockControl(f, DockPosition.Fill, DockType.Document)
    hostW.Text = strPage
End Sub

As to your second question, please note that you should create a new instance of your form each time AddPage is called. If you use only one form instance, it will not be added to the second HostWindow as it has already been added to the first HostWindow:
Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    frmProject = New Form2()
    AddPage(frmProject, "frmProject")
End Sub

I hope this helps.

Sincerely yours,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Dock
Asked by
R.H.B. Haukes
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or