Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Can anybody tell me how to speed up the process of loading controls into windows form, i have a windows form in which i have added a flowlayoutpanel & few buttons into it. This keeps varying based on the buttons required by the user. Basically it has 25 rows & 4 columns or sometimes 12 row & 4 columns. The user can choose any of these options, once the user selects or clicks on the particular option, all the previously present formation is cleared & chosen 1 is formed. During this time a huge delay is observed. How to increase the speed of such operation....? I have set doublebuffered to true but still no use.

Also i tried with this piece of code,

C#
protected override CreateParams CreateParams
     {
         get
         {
             var parms = base.CreateParams;
             parms.Style &= ~0x08000000; 
             return parms;
         }
     }

All in vain. So any help will be appreciated.

Thanks in advance.
Posted

1 solution

i can suggest two options:
1. use SuspendLayout and ResumeLayout methods
C#
flowPanel.SuspendLayout();
flowPanel.Controls.Clear();
// add controls to flowPanel here
flowPanel.ResumeLayout();


2. remove current flowPanel and create a new one with the same properties
C#
// this = current form
this.SuspendLayout();
this.Controls.Remove(flowPanel);

var fp = new FlowLayoutPanel();
fp.Location = new Point(100,10);
fp.Size = new Size(200,200); 
// set other fp properties

// add controls to fp here

this.Controls.Add(fp);
this.ResumeLayout();
 
Share this answer
 
Comments
Nattawutxp 5-Sep-19 3:23am    
excellence, ...
I've been searching for a long time.
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900