Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to load all UI controls before displaying? C# winform

I have a complicate win form with lots of controls and bulky repaints, controls resizeing and positioning according to user screen, this causes the form to be shown while doing some rendering and repainting.

Is there any way to load UI and prepare it before displaying??I mean showing final UI after the whole repainting events done.

If using splash screen, before loading the main form, how should I do that??

Thanks

like image 606
Nabil Avatar asked Feb 27 '23 16:02

Nabil


2 Answers

Perhaps using SuspendLayout() and ResumeLayout() would work.

From MSDN:

The SuspendLayout and ResumeLayout methods are used in tandem to suppress multiple Layout events while you adjust multiple attributes of the control. For example, you would typically call the SuspendLayout method, then set the Size, Location, Anchor, or Dock properties of the control, and then call the ResumeLayout method to enable the changes to take effect.

like image 184
Andy West Avatar answered Apr 09 '23 18:04

Andy West


@Kevin has the right idea and it's the approach I would use:

  1. Drop a Panel on your form and set Dock to Fill so that it covers the entire form.
  2. Drop a ProgressBar into the center of the panel with the Style property set to Marquee. This will make it scroll constantly.
  3. Now, at the end of your form's constructor (or Load event handler, if you are using it), call the SendToBack() method of your panel to expose the fully rendered controls.
like image 21
Ken Avatar answered Apr 09 '23 18:04

Ken