-
Jan 7th, 2018, 03:03 AM
#1
Thread Starter
Addicted Member
[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.
-
Jan 7th, 2018, 02:11 PM
#2
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?
-
Jan 8th, 2018, 04:09 AM
#3
Thread Starter
Addicted Member
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
-
Jan 8th, 2018, 02:31 PM
#4
Re: Forms docking problem in splitcontainer control under MdiForm
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?
-
Jan 9th, 2018, 03:54 AM
#5
Thread Starter
Addicted Member
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
-
Jan 9th, 2018, 09:37 PM
#6
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.
-
Jan 11th, 2018, 05:08 AM
#7
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|