|
-
Sep 19th, 2007, 11:07 PM
#1
Thread Starter
Lively Member
Fully load before showing
Hi there
How do I make a windows form fully load before showing itself. This is so no one can see all the controls setting it self up when I say form1.show()
Thanks in advance.
-
Sep 19th, 2007, 11:33 PM
#2
Re: Fully load before showing
That already happens. The controls are all created in the InitializeComponent method, which is called from the constructor, before you even call Show. If there's an issue it's because your controls are painting slowly. This should not be a problem in most UIs. If it is for you then setting the form's DoubleBuffered property to True may help.
-
Sep 20th, 2007, 12:23 AM
#3
Thread Starter
Lively Member
-
Sep 20th, 2007, 12:25 AM
#4
Re: Fully load before showing
-
Sep 20th, 2007, 02:35 AM
#5
Thread Starter
Lively Member
Re: Fully load before showing
I haven't got the code with me right now, but I can make something similar up to give you a better idea.
Private sub form1_load(byval sender as object, e as system.eventargs) handles me.load
for each btn as button in Groupbox1.controls
btn.backgroundImage = my.resources.bluebutton
next
end sub
Private sub Button1_Click(byval sender as object, e as system.eventargs) handles button1.click
for each btn as button in Groupbox1.controls
btn.backgroundImage = my.resources.redbutton
next
groupbox1.location = new point(100,100)
groupbox2.visible = true
end sub
Sorry about the colours not being there, I typed the code dirrectly on here.
Last edited by Developer2007; Sep 20th, 2007 at 02:38 AM.
-
Sep 20th, 2007, 04:45 AM
#6
Re: Fully load before showing
I can't quite see why you'd be setting the BackgroundImage of the Button's from resources in the Load event handler when you can set them at design time.
-
Sep 20th, 2007, 06:13 PM
#7
Thread Starter
Lively Member
Re: Fully load before showing
-
Sep 21st, 2007, 06:51 AM
#8
Re: Fully load before showing
 Originally Posted by jmcilhinney
I can't quite see why you'd be setting the BackgroundImage of the Button's from resources in the Load event handler when you can set them at design time.
What is the answer to this? I share the confusion.
-
Sep 21st, 2007, 08:53 AM
#9
Re: Fully load before showing
If I had to guess, based on the fact that he changes them to red buttons in a button click, that it may be some sort of skinning effect he is going for.
If I recall correctly the Form_Load code will complete before the form is shown unless you explicitly set Me.Visible = True.
-
Sep 21st, 2007, 09:24 AM
#10
Re: Fully load before showing
try this... before you start changing the images... jsut before your loop add this:
me.SuspendLayout
Then after the loop and you are done changing things add this:
me.ResumeLayout
See if that helps.
-tg
-
Sep 21st, 2007, 10:10 AM
#11
Re: Fully load before showing
I agree, the basic problem is that the screen is refreshing faster than your changes are happening, and each individual change is repainting. What you want to have happen is that all the changes are made, then the whole form re-draws itself. What TG suggested might cover it. You might look up the DoubleBuffering, but I'm not sure that will necessarily work in this case, as I think the drawing will be too slow for double buffering to completely take care of the case.
My usual boring signature: Nothing
 
-
Sep 21st, 2007, 10:41 PM
#12
Thread Starter
Lively Member
Re: Fully load before showing
The following as I said is only a sample to give everyone an idea of what the situation is. I'm fully aware of what a waste of time it would be to load all the buttions red when you could have don't that during design time. Just an example guys\girls.
Thanks for all the repies, I will be trying the suspend layout and resume layout to see if it is any better. I'll give you an update on how it went once my cold get's better, hopefully this will solve the problem.
More suggestions are welcome, I will test them all once I feel better.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|