Results 1 to 7 of 7

Thread: [RESOLVED] Forms docking problem in splitcontainer control under MdiForm

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    Resolved [RESOLVED] Forms docking problem in splitcontainer control under MdiForm

    I'm using SplitContainer (It's contain two panels) control under my MdifForm.I'm using following code to showing my exist forms under SplitContainer panel2

    Code:
    With My_Form
            .MdiParent = Me
            SplitContainer.Panel2.Controls.Add(My_Form)
            .My_Form_Activated(Me, e)
            .WindowState = FormWindowState.Maximized
            .Dock = DockStyle.Fill
            .Show()
        End With
    Docking fill command work properly at first displaying of the My_Form. But after mdiform resizing, my_form size doesn't change. How can i fix this problem thanks.

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Forms docking problem in splitcontainer control under MdiForm

    There is a conflict between Dock and WindowState

    Code:
            With My_Form
                .MdiParent = Me
                SplitContainer.Panel2.Controls.Add(My_Form)
                .My_Form_Activated(Me, e)
                '.WindowState = FormWindowState.Maximized
                .FormBorderStyle = FormBorderStyle.FixedDialog ' To prevent showing resize cursor when trying to resize the MDI parent
                .MaximizeBox = False
                .Dock = DockStyle.Fill
                .Show()
            End With
    Anyway you cannot prevent moving My_Form from its titlebar

    What is the idea of using Form inside SplitContainer?



  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    Re: Forms docking problem in splitcontainer control under MdiForm

    Hi 4x2y,

    My forms borderstyle defined as none because i don't want to user see the form borders.
    I divided window two part with SplitContainer control .
    I'm displaying some graphics object in top panel and user enter data with using my_forms obejct in panel2.
    Problem still continue

    Thanks

  4. #4
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Forms docking problem in splitcontainer control under MdiForm

    Problem still continue
    Did you tried my above solution?

    Borderless form makes things easier
    Code:
            With My_Form
                .MdiParent = Me
                SplitContainer.Panel2.Controls.Add(My_Form)
                '.My_Form_Activated(Me, e)
                .FormBorderStyle = FormBorderStyle.None
                .Dock = DockStyle.Fill
                .Show()
            End With
    Again why you don't use Panel container instead of Form?



  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    Re: Forms docking problem in splitcontainer control under MdiForm

    Hi 4*2y

    Yes i tried your code but form doesn't display when i remove ".WindowState = FormWindowState.Maximized" code.

    I don't use panel container because i have to many forms and there are to many code under these forms.

    Thanks

  6. #6
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Forms docking problem in splitcontainer control under MdiForm

    I see, the code works fine for displaying only one Form, but in your case you have many, so you must remove the existing form before adding the new one, try this
    Code:
    Option Strict On
    Option Explicit On
    
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            ShowForm(Form2)
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            ShowForm(Form3)
        End Sub
    
        Private Sub ShowForm(frm As Form)
            Dim blnExist As Boolean = False
            'Check if the form is already in SplitContainer.Panel2
            If SplitContainer1.Panel2.Controls.Count > 0 Then
                If frm.Equals(SplitContainer1.Panel2.Controls(0)) Then
                    blnExist = True ' the same form, keep it.
                Else
                    SplitContainer1.Panel2.Controls.RemoveAt(0) ' different form, remove it.
                End If
            End If
    
            If Not blnExist Then
                With frm
                    .MdiParent = Me
                    SplitContainer1.Panel2.Controls.Add(frm)
                    .FormBorderStyle = FormBorderStyle.None
                    .Dock = DockStyle.Fill
                    .Show()
                End With
            End If
        End Sub
    
    End Class
    Last edited by 4x2y; Jan 9th, 2018 at 09:41 PM.



  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    222

    Re: Forms docking problem in splitcontainer control under MdiForm

    Thanks 4x2y for the solution

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width