In my application, I really needed to place a lot of controls (label, textbox, domainupdown) in good order. So I went ahead and used a few nested TableLayoutPanel . The problem is that this form reacts very slowly to most events (resizing, maximizing, minimizing and ...) so that the controls in the tables change in size up to 5 seconds, redraw to the new size of the form.
Now I put a finger on my eye! If this form is slow on my home PC (i7 @ 4GHz and a good graphics card), what will it do for the old P4 computer at work?
I even tried using the code below, but it does absolutely nothing unless it slows it down anymore!
private void FilterForm_ResizeBegin(object sender, EventArgs e) { foreach(TableLayoutPanel tlp in panelFilters.Controls) { if(tlp != null) { tlp.SuspendLayout(); } } } private void FilterForm_ResizeEnd(object sender, EventArgs e) { foreach (TableLayoutPanel tlp in panelFilters.Controls) { if (tlp != null) { tlp.ResumeLayout(); } } }
Please let me know if there is a trick to get the tablelayoutpanel to work faster ... or if you know a better approach to stack about a hundred controls that are evenly aligned.
performance c # winforms tablelayoutpanel
Saeid yazdani
source share