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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Maximized" MDI Child without Controlboxes VB 2005

How-to

"Maximized" MDI Child without Controlboxes VB 2005

by  VBRob  Posted    (Edited  )
Our company needed an MDI form where the children were always maximized and would not let the user minimize or restore the children forms. Also needed to be able to navigate between the child forms.

Setting the children's Controlbox, MinBox and MaxBox to false also setting the windowstate = Maximize and FormBorderStyle = None didn't work. The parent still contained the control boxes to minimize, restore or close the child form.

After trying several variations, we came up with the following solution which worked exactly the way we needed it to. Simply create a project with three forms setup as specified below. It should look similar to this:
[img http://www.renrob.com/pubImg/MDI.gif]


[red]Setup:[/red]
Form1 Properties:
IsMdiContainer = True

Listbox1 docked to left of Form1.
ImageList1 contains one image.

Form2 and Form3 Properties:
WindowState = Normal

Form2 has a label with Label1.Text = "2"

Form3 has a label with Label1.Text = "3"

[red]CODE:[/red]
Code:
Public Class Form1
    Dim frm2 As New Form2
    Dim frm3 As New Form3

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        frm2.MdiParent = Me
        frm2.Dock = DockStyle.Fill
        Me.ListView1.Items.Add(frm2.Text, 0)
        frm2.Show()
        frm3.MdiParent = Me
        frm3.Dock = DockStyle.Fill
        Me.ListView1.Items.Add(frm3.Text, 0)
        frm3.Show()
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        Dim lv As ListView = CType(sender, ListView)

        Select Case lv.FocusedItem.Text
            Case frm2.Text
                frm3.Hide()
                frm2.Show()
            Case Else
                frm2.Hide()
                frm3.Show()

        End Select
    End Sub
End Class
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top