vb.netdockingdockpanel-suite

How to have two forms docked on same side (Weifenluo)


I've been searching quite a lot and studying the Docksuite sample but haven't been successful in getting a simple screen working. I would like to have a form on top and two forms opened on the left.

What I have done so far:

  1. Created a FormMainDock that holds a DockPanel; isMDIContainer = True
  2. Created three Forms that inherit from DockContent
  3. In the FormMainDock have the following code:

...

Private Sub FormMainDock_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  Me.DockPanel1.Theme = New VS2015DarkTheme
  Dim fTop As New FormTop
  fTop.Show(DockPanel1, DockState.DockTop)
  fTop.DockPanel.DockTopPortion = 120

  Dim fLeft1 As New FormLeft1
  fLeft1.Show(DockPanel1, DockState.DockLeft)

  Dim fLeft2 As New FormLeft2
  fLeft2.Show(DockPanel1, DockState.DockLeft)
  fLeft2.DockPanel.DockLeftPortion = 400

End Sub

...

and that shows me

Example 1

Now what I would like to have is this

Example 2

I have no idea how to get the two forms opened on startup. Any help would be appreciated.


Solution

  • Even though I already looked at the demo source, I looked again, knowing that this code worked and the tip from Lex Li to look at it again I forced myself to dive a bit deeper, and with the help of some C# translators I figured it out. Of course in the end it is quite simple. So for anyone else to solve it quicker here is all you have to do:

    First, create a MainForm that holds a DockPanel and set isMDIContainer = True. Create three Forms that inherit from DockContent (don't forget to Import the WeifenLuo.WinFormsUI.Docking). Then when you want to get the sample that is in the picture use this:

    Private Sub FormMainDock_Load(sender As Object, e As EventArgs) Handles MyBase.Load
      Me.DockPanel1.Theme = New VS2015DarkTheme 'This line isn't necessary
    
      Dim fTop As New FormTop
      fTop.Show(DockPanel1, DockState.DockTop)
    
      Dim fLeft1 As New FormLeft1
      fLeft1.Show(DockPanel1, DockState.DockLeft)
    
      Dim fLeft2 As New FormLeft2
      fLeft2.Show(fLeft1.Pane, DockAlignment.Bottom, 0.5)
    End Sub
    

    That's all. Have fun with it.