showing forms in panel

liam

Member
Joined
Jun 8, 2004
Messages
23
Programming Experience
Beginner
i've got the code for showing forms in panel but the problem is i want the form to appear only once even if the button is clicked many times.

here's the code.. hope someone could help me...

Sub LoadFormsInPanel(ByVal container As Panel, ByVal formType As Type)

Dim ypos As Integer = 0

container.Visible = False

For index As Integer = 0 To index = 1 'dataArray.Length - 1

'Create an instance of the form via Reflection.

Dim frm As Form = DirectCast(Activator.CreateInstance(formType), Form)

'Drop titlebar and border and make it a non-toplevel form.

frm.FormBorderStyle = FormBorderStyle.None

frm.TopLevel = False

'Set its position and size.

frm.Top = ypos

frm.Width = container.Width - 4

'Add the form to the panel and make it visible.

container.Controls.Add(frm)

frm.Visible = True

'Prepare position of next form.

ypos += frm.ClientSize.Height

Next

container.Visible = True

End Sub

 
all i can suggest is that you have a module level boolean variable set to false at startup then when the button is clicked right before anything else is done check the boolean to see if it's true or false, if it's true then set the boolean false else exit the sub
 
Back
Top