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.
Printable View
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.
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.
Hey,
Sorry I should of made it more clearer. In my form load event, I change background images of controls. The problem is that people can see one control by one changing images when it loads up:mad: .
Also there is a specific button on the page that again changes the background images of all the controls on the page and some controls shift to the side of the page. you can see the changes to the GUI one by one here too.
Is there away around this for at least one of the situations????:confused: :eek2:
Can we see this code?
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.
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.
Some one help please
What is the answer to this? I share the confusion.Quote:
Originally Posted by jmcilhinney
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.
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
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.
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.