Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically Populated TableLayoutPanel Performance Degredation
    primarykey
    data
    text
    <p>I have a user control that contains a 2-column TableLayoutPanel and accepts commands to dynamically add rows to display details of an item selected in a separate control. So, the user will select a row in the other control (a DataGridView), and in the SelectedItemChanged event handler for the DataGridView I clear the detail control and then regenerate all the rows for the new selected item (which may have a totally different detail display from the previously selected item). This works great for a while. But if I keep moving from one selected item to another for quite a long time, the refreshes become VERY slow (3-5 seconds each). That makes it sound like I'm not disposing everything properly, but I can't figure out what I'm missing. Here's my code for clearing the TableLayoutPanel:</p> <pre><code>private readonly List&lt;Control&gt; controls; public void Clear() { detailTable.Visible = false; detailTable.SuspendLayout(); SuspendLayout(); detailTable.RowStyles.Clear(); detailTable.Controls.Clear(); DisposeAndClearControls(); detailTable.RowCount = 0; detailTable.ColumnCount = 2; } private void DisposeAndClearControls() { foreach (Control control in controls) { control.Dispose(); } controls.Clear(); } </code></pre> <p>And once I get finished loading up all the controls I want into the TableLayoutPanel for the next detail display here's what I call:</p> <pre><code>public void Render() { detailTable.ResumeLayout(false); detailTable.PerformLayout(); ResumeLayout(false); detailTable.Visible = true; } </code></pre> <p>I'm not using anything but labels (and a TextBox very rarely) inside the TableLayoutPanel, and I add the Labels and TextBoxes to the controls list (referenced in DisposeAndClearControls()) when I create them. I tried just iterating over detailTable.Controls and disposing them that way, but it seemed to miss half the controls (determined by stepping through it in the debugger). This way I know I get them all.</p> <p>I'd be interested in any suggestions to improve drawing performance, but particularly what's causing the degradation over multiple selections.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload