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

Multiple subforms into Panel?

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
The following is related to a Mobile .NET application I am experimenting with.

I have a main form, which has the following controls:
2 x Combo boxes.
1 x Command Button
1 x Panel control

I then have two (at this stage but it will increase) other forms. I want to load the forms into the panel on the main form, based on the selection in the combo boxes.

At this stage I am only concerned with the input from one of the Combo boxes. I wrote the following to load the subform into the Panel control:
Code:
    Private Sub cboAssetType_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboAssetType.SelectedValueChanged
        Dim i As Integer
        For i = 0 To Me.Panel1.Controls.Count - 1
            Me.Panel1.Controls.RemoveAt(i)
        Next
        Select Case Me.cboAssetType.Text
            Case "Tree"
                Dim frmT As New frmTree
                'Load tree form
                Panel1.Controls.Add(frmT)
                frmT.Show()
            Case "Fence"
                Dim frmF As New frmFence
                'Load fence form
                Panel1.Controls.Add(frmF)
                frmF.Show()
        End Select
    End Sub

This works for the first selection, & the correct subform is displayed in the panel:
1.jpg


However, if I then select a second form from the combo, the existing form seems to be maximised:
2.jpg



Any suggestions?

James Goodman MCSE, MCDBA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top