Opening form invisible

J

John

Hi

Is there a way to open a form hidden/invisible while it is populating its
controls, and then make it visible once it is done? I am using the following
code but the form remains visible.

cform = New frmClients
cform.Visible = False ' this does not seem to make form hidden (not
visible)
cform.TopLevel = False
Me.FormsPanel.Controls.Add(cform) 'Me is a main/parent form
cform.Show()
cform.BringToFront()
cform.Visible = True

Thanks

Regards
 
C

Cor Ligthert

Hi John,

When you do your loading in the "load" event from the form, it is invisible
untill that is ready. The first event with a visible form I use is the form
activated.

I hope this helps?

Cor
 
H

Herfried K. Wagner [MVP]

* "John said:
Is there a way to open a form hidden/invisible while it is populating its
controls, and then make it visible once it is done? I am using the following
code but the form remains visible.

cform = New frmClients
cform.Visible = False ' this does not seem to make form hidden (not
visible)
cform.TopLevel = False
Me.FormsPanel.Controls.Add(cform) 'Me is a main/parent form

The form will remain invisible until the execution of the next line.
cform.Show()
cform.BringToFront()
cform.Visible = True

The last line doesn't make sense because the form is already visible.
 
J

John

The problem is that I see the controls being painted one by one. Can I not
keep the form hidden until all controls are painted during the first form
loading?

Thanks

Regards
 
J

John

The problem is that I see the controls being painted one by one. Can I not
keep the form hidden until all controls are painted during the first form
loading?

Thanks

Regards
 
H

Herfried K. Wagner [MVP]

* "John said:
The problem is that I see the controls being painted one by one. Can I not
keep the form hidden until all controls are painted during the first form
loading?

Google for 'SendMessage' + 'WM_SETREDRAW', maybe this will work for you.
 
O

One Handed Man \( OHM#\)

Private Sub CreateForm_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

' mhf is a form declared at class level

mhf.Visible = False

For x As Integer = 0 To 20

mhf.Controls.Add(New Windows.Forms.Button)

Next

End Sub

Private Sub MakeVisible_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

mhf.Visible = True

End Sub

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top