loading a form

genu

Well-known member
Joined
Jun 9, 2005
Messages
94
Programming Experience
1-3
How do you make it so it loads a form? for example: FORM1 is not visible, but its loading into memory and it has a progress bar. when the form is loaded into memory, the progressbar goes to 100% and then progressbar closes and form just shows..

thx in adavance
 
i think you have to use a dialog in which u can put a progress bar which will show the progress. and this all code will be in ur Form_Load event , u even dont need to use Form.Show as when ur code finsihes u r done
Form_Load
Dlg.Show [Dialog will have ur progress bar logic]
End Sub

this is only possible if u only want to show progress bar to delay the intilization but if you want to do any processing on that form then i can have other solutions as well.
 
yeah thats what i was saying if u need to do any processing along with it , then either u can use Threading or Timer both will help you, but i ll recomend Threading.
 
genu said:
which for would I put that in?

Sorry, the code to your "loading" form.

Me.Show
'Code to show progress:

What is happening is that whatever you have in the load event of the loading form is going on before it is visible. This is how I always handled it in VB6. I'm still transitioning to .net. But it works for .net too
 
Note that most of the initialisation of a form takes place in the constructor, with some actions often added in the Load event handler. To show accurate progress for the creation of a form you would have to put statements all through that code to set the progress bar's Value property. I think it would be far better to simply show some animation that indicates that the form is being loaded, rather than exactly what stage it is up to.
 
I'll agree with that. You could do it the photoshop way and just have it say what it's working on. Or, yeah, just something that shows the user that it's doing something.
 
how do I do that
I tried

VB.NET:
WHILE InitializeComponent()
dim form2 as new form2
form2.showdialog
End While


but that gave me error because InitializeComponent() does not produce a value
 
when u r doing wrong it will be wrong, my dear what i got your try that you want to load some heavy components and you want to show a progress bar in between...
so i would suggest you that first clear us what you are doing and then we can suggest u an optimal solution.
 
I want to show loading aninm....basically anoter form...because there is a delay between when I click the program and when it shows up...so IM guessing that initializexomponent() is the cause of this delay.(maybe becaues infact i do have a lot of control on the form) so I already have form 2 done with a loading animation...now how do I make that come up while initialize component is working to build the form
 
hmm now i got what you want to do , ok just give it to try not cripple with initlize event
just use following code bofre the call of initialize method in your constructor.

FormAnimation.show
Initailize_Components
FormAnimation.Close


now what i suppose that you are not requiring any kind of data to show up on the other form just simple animation
oh yeah it may possible that your form has not set itf focus in this case u can use to activate event to get ur focus.
 
here is what I have :

Dim loading As New loading
loading.ShowDialog()
'This call is required by the Windows Form Designer.
InitializeComponent()
loading.Hide()

and its weird that when I run this...i just shows the loading form but never the form1 from the initializecomponent
 
A call to ShowDialog does not return until you dismiss the dialogue. Let's say you have a form of type AnimationForm that contains an animated GIF that indicates that a form is loading. Simply use code like this from wherever your slow-loading form gets displayed from, whether that be a Main procedure or another form:
VB.NET:
Dim af As New AnimationForm

af.Show()

Dim sf As New SlowForm

sf.Show()
af.Close()
 
Back
Top