Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child forms in MDI 2

Status
Not open for further replies.

sacsac

Programmer
Dec 10, 2000
182
GB
In VB6 it seemed simple to create a Child form to open inside an MDI form - I just set the property MDICHild to True. I just can't discover how to do this in .NET. Can anyone help me?
 
Try this:

Code:
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        Dim a As Form1
        a = New Form1
        a.MdiParent = Me
        a.Show()

    End Sub

I hope this helps.



Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Also, set the IsMdiContainer to TRUE of the parent-MDI form of yours.
 
..many thanks - that all works fine, but leads on to a further issue which I can't fathom out! I am in the habit (in VB6) of making my child forms fixed size and unmoveable when displaying in the MDI. I can do the fixed size bit in .NET, but just can not discover how to make the child form unmoveable (i.e. pinned to the top left of the MDI display area). Any ideas?
 
Hi,
I cannot imagine why you would need to be not-movable or how could this help you. Anyway, you could set the child's formborderstyle to none.

?
 
TipGiver - you're quite right about questionning why I even want the form to be not-moveable! I've considered it more and it really if a naff way of going about things. I will start using the more acceptable convention of letting forms be arranged as the user sees fit!
Thanks for answering anyway.
 
I'm not sure if it would work, but you could try creating an MDI Container form and adding it to a non-MDI Container form. That should allow you to have fixed elements on the parent form and a MDI are in the child form.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Yes, you should let the user move the children. To arrange use Me.LayoutMdi(...).
Else, to have them freezed, I would not have childforms but 'user controls'. So i would create them and place them on the parent form (no need for mdi) at runtime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top