c# - Improve control rendering performance in a TabControl -


my windows forms application has large tabcontrol select view user wants (customer management, other special list management, log list, etc.). each tab page contains nothing special, it's bunch of standard controls, layouted through tablelayoutpanels , flowlayoutpanels. these labels, textboxes, comboboxes, listboxes , on.

when switch tab page, can literally watch windows forms painting controls on screen. in first moment, background of controls seems partially painted, other regions, text, , few rendering frames later painted , complete.

there no event handler on tabcontrol nothing delay switching. tab switching quick, it's rendering of stock controls doesn't happen in 1 step progressively. user should not see. controls static. don't re-arrange or dynamically create them @ runtime. there doesn't have content. can see on new tab page i've designed , isn't filled data yet. have never seen such partial updates wpf, it's winforms issue.

what cause of behaviour , can fix it? possible @ atomic screen updates windows forms?

sometimes use suspendlayout , resumelayout, don't perform layout here, there's no line of code put calls into. it's default tabcontrol behaviour.

using vs 2010 .net 4.0, problem exists years.

you definetely see layouting process of tablelayoutpanel , flowlayoutpanel combined not-double-buffered painting.

first 1 easy solve suspendlayout()/resumelayout(). surround dynamic control adding. if don't change tablelayoutpanel.controls collection, perhaps still need first draw (this depends on complicity, nested containers problem).

second 1 required tweaking

[system.componentmodel.designercategory("code")] public class xtablelayoutpanel : tablelayoutpanel {      [defaultvalue(typeof(color), "transparent")]     public new color backcolor     {         { return base.backcolor; }         set { base.backcolor = value; }     }      public xtablelayoutpanel()     {         // set user paint style         setstyle(controlstyles.userpaint | controlstyles.resizeredraw | controlstyles.doublebuffer | controlstyles.allpaintinginwmpaint, true);         backcolor = color.transparent;     }      protected override void onpaint(painteventargs e)     {         // nothing     } } 

winform problem itself, containers (which must scalable or localizable applications) not fitting redrawing process. consider use wpf future projects, has layouting build redrawing (if can spell way).


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -