VB 6 Load method equivalent in .net? (Loading a form invisibly)

  • Thread starter Thread starter Mr. Analogy
  • Start date Start date
M

Mr. Analogy

I'd like to load a form in the background (invisibly) and then, afer
the controls are all drawn (and resized, in this case), I'd like to
show it. I.e., I want the form to show up nice and crisply, without
showing the user a form building (kinda scary to a non technical user
;-)

I've tried:

Dim f As New Form1
f.Visible = False
f.Show()
f.Visible = True

However the show method makes the form visible momentarily (thus you
get a "flash" of the form, defeating the whole purpose).
 
Pardon me if I am wrong, but as soon as you issue:

Dim f As New Form1

then the form is as good as loaded and invisible until you SHOW it.
 
Unfortunately, no it isn't.

The controls on the form aren't yet instantiated.

You can see this If you look at the form immediately after Dim'ing
it, you'll see that f.controls.count=0 (there were controls on the
form).
 
Controls aren't available (instantiated) until the Load() event fires.
And the form becomes visible when the load() event fires.
 
Mr. Anoalogy

Where do you have this code in your application?
Dim f As New Form1
f.Visible = False
f.Show()
f.Visible = True

I think that it can explain than something more

Cor
 
Have a look at the "opacity" property

eg putting "Me.Opacity = 0" in the form's constructor

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

Me.Opacity = 0

End Sub





Jon
 
Hi,

Take a look at the forms suspendlayout and resumelayout methods

http://msdn.microsoft.com/library/d...indowsformscontrolclasssuspendlayouttopic.asp

http://msdn.microsoft.com/library/d...windowsformscontrolclassresumelayouttopic.asp

Ken
-------------------
I'd like to load a form in the background (invisibly) and then, afer
the controls are all drawn (and resized, in this case), I'd like to
show it. I.e., I want the form to show up nice and crisply, without
showing the user a form building (kinda scary to a non technical user
;-)

I've tried:

Dim f As New Form1
f.Visible = False
f.Show()
f.Visible = True

However the show method makes the form visible momentarily (thus you
get a "flash" of the form, defeating the whole purpose).
 

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

Back
Top