c# - Dynamically creating Table Layout Panel takes too long -


i working on winforms application in c#. have table layout panel populate dynamically created buttons, 1 each cell. works well, , quite fast. during program execution, have clear table layout panel , repopulate it, pretty same display, more buttons (twice number initial table). problem process takes lot of time (over 10 seconds). doing wrong? code:

buttontable.controls.clear(); buttontable.cellborderstyle = tablelayoutpanelcellborderstyle.single; buttontable.rowcount = getnooflines(); buttontable.columncount = getnooflines();  (int z = 1; z <= getnooflines(); z++) {     buttontable.columnstyles.add(new columnstyle(sizetype.absolute, 25));     buttontable.rowstyles.add(new rowstyle(sizetype.absolute, 25)); }  (int = 1; <= getnooflines(); i++) {     (int j = 1; j <= getnooflines(); j++)     {         fieldbutton tempbutton = new fieldbutton(i, j, getnooflines());         tempbutton.mousedown += new mouseeventhandler(onfieldbuttonclicked);          buttontable.controls.add(tempbutton, j - 1, - 1);      }  } 

note: fieldbutton class derived button, i've added 2 int's, nothing special it. also, buttons added correctly table. thanks!

i had problems tablelayoutpanel performance until read this thread , created custom control set doublebuffered property.

public class doublebufferedtablelayoutpanel :tablelayoutpanel {     public doublebufferedtablelayoutpanel()     {         doublebuffered = true;     } } 

try control instead of standard tablelayoutpanel. second advice suspend , resume layout while you're populating table.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -