Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

Designing Child Form Layout in VB.NET

I have an MDI Parent form, in which I dock multiple child forms which contain a custom menu strip, TreeView, etc. In the MDI Parent form_loading event I instantiate two forms and dock them to the left and top of the Parent form, respectively. When I instantiate a third form and set it to fill the Parent, on load it behaves correctly and fills the remaining space. However, when the menu strip receives focus, the third child form slides underneath the menu strip as if the menu strip form executed a Me.BringToFront method.

I have coded methods to counteract any form going forward or backward upon getting / loosing, but the problem remains. It's driving me crazy. Any help is greatly appreciated.
0
fieldb1
Asked:
fieldb1
  • 5
  • 5
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Can you show a screen shot of the layout please?
0
 
fieldb1Author Commented:
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I think we'd need to see some code and understand better how the subforms were built...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fieldb1Author Commented:
Got it!

In the TreeView_GotFocus event I placed the following code:
If Not anAccountForm Is Nothing Then
            anAccountForm.BringToFront()
            Me.SendToBack()
        End If

Thank God! I've been banging my head on this.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
In the picture, which controls are part of what form(s)?

Are you really using MDI here?...or setting TopLevel to False and embedding the forms?
0
 
fieldb1Author Commented:
I'm using an MDI Parent yes.

In the picture, the parent form consists of a toolstrip and status strip
The left hand child form contains the treeview
The middle child currently contains textboxes.

What is this TopLevel to false useful for?
0
 
fieldb1Author Commented:
You wouldn't know the TSQL syntax for inserting rows from one database into a table in a different database, would you? I'm using fully qualified names, but it throws an error.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
No, sorry...I'm not a DB guy.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Instead of an MDI form, you can use Panels on the main form as placeholders for the subforms (set the Docking for the Panels).

Then you display your subforms directly in the panels by setting TopLevel() = False and adding them like normal controls to the Panels.  Set Dock = Fill for the subforms.


Something like:

    Dim f2 As New Form2
    f2.TopLevel = False
    f2.Dock = DockStyle.Fill
    f2.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    Me.Panel1.Controls.Add(f2)
    f2.Show()

Not sure if it will fix the issue or not...
0
 
fieldb1Author Commented:
I fixed it (see my earlier post) but I accept this as a good alternative. Thanks.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now