Custom Child Forms

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
4 posts Page 1 of 1
Contributors
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Custom Child Forms
smashapps
It is easy to declare child forms and display them in an MDI container, but alot of people create new forms and have trouble to add controls and position them because its all coded O.o

Well you can make your own form, create your MDI container, and then display your form as a child form inside of the MDI container.

I know its easy, but I am sure that SOMEONE will find this useful. MDI stands for Multiple Document Interface and is used for displaying multiple windows in one form, for example my game maker uses an MDI container to display all of the forms.

You will need two forms, Form1 is our Parent Form, set the properties to IsMdiContainer value to True, your form will turn into an ugly gray form.

Create another form, it can be any type of form and have anything that you want on it.

On my Parent form I used a button to display the child form, here is the code I used:
Code: Select all
Dim ChildFormNumber As Integer = 0

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim CustomChildForm As New ChildForm
        ChildFormNumber += 1
        CustomChildForm.Text = "ChildForm " & ChildFormNumber
        CustomChildForm.MdiParent = Me
        CustomChildForm.Show()
    End Sub
ChildFormNumber is an integer I created to show the number on the form "ChildForm 1", "ChildForm 2" etc.

I declare my form as CustomChildForm, set the text on top of the form, and most importantly I set the MdiParent to my Parent Form. If you do not set the MdiParent it will display as a normal Form.

Here is a screen shot:

Image

I don't mean to be spamming with my tutorials or anything just trying to help people out, I do have more tutorials I want to share but I am going to wait until tomorrow or something, and that's how to set an image and color for the Mdi Container so its not just an ugly gray background ;)

Source code plus if you liked my tutorial please feel free to +rep me :)
You do not have the required permissions to view the files attached to this post.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
hungryhounduk
VIP - Site Partner
VIP - Site Partner
Posts: 2870
Joined: Mon Jul 27, 2009 11:58 am

Re: Custom Child Forms
hungryhounduk
Hey Smash

Nice one for the Tutorial

keep it up

Chris
Image
User avatar
clanc789
Coding Guru
Coding Guru
Posts: 786
Joined: Tue Nov 02, 2010 4:45 pm

Re: Custom Child Forms
clanc789
Cant +rep since i did not REP anyobdy b4 i repped you LOL
Practice makes perfect!

VIP since: 6-10-2011
User avatar
Frozen
VIP - Donator
VIP - Donator
Posts: 46
Joined: Thu Jul 21, 2011 8:34 pm

Re: Custom Child Forms
Frozen
See this is what I love about Code'N'Stuff all the members are nice and we all create great things :). Rep+
4 posts Page 1 of 1
Return to “Tutorials”