Open several winforms on dock

2 posts, 0 answers
  1. R.H.B. Haukes
    R.H.B. Haukes avatar
    2 posts
    Member since:
    Apr 2010

    Posted 26 May 2010 Link to this post

    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,
  2. Nikolay
    Nikolay avatar
    1805 posts

    Posted 28 May 2010 Link to this post

    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,
    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.
Back to Top