Note that there are some explanatory texts on larger screens.

plurals
  1. POSuper slow C# custom control
    text
    copied!<p>I've made a custom control, it's a FlowLayoutPanel, into which I put a bunch of other custom controls (just Buttons, each with three Labels and a PictureBox overlayed)</p> <p>It works ok with around 100 buttons, but bump that up to 1000 and it's in trouble. Bump that up to 5000 and it just dies after 20 seconds.</p> <p>I have very little custom code, and I make judicious use of suspend and resume layout.</p> <p>So what am I doing wrong? I'm sure my (fairly rapid) computer should be able to handle a few thousand buttons and labels.</p> <p>(I'm fairly new to C# GUI stuff, so perhaps I should be doing things completely different anyway.)</p> <p>Edit 1:</p> <p>This is pretty much the only custom code at the moment:</p> <pre><code>flowLayoutPanel1.SuspendLayout(); foreach (DataRow row in dt.Rows) // dt is from a DB query { flowLayoutPanel1.Controls.Add(new PersonButton(row)); } flowLayoutPanel1.ResumeLayout(); </code></pre> <p>and in the PersonButton constructor:</p> <pre><code>this.label1.Text = row["FirstName"].ToString().Trim() + " " + row["Surname"].ToString().Trim(); </code></pre> <p>(There should also be a picture attached but I'm not sure if anyone can see it.)</p> <p>Edit 2:</p> <p>I guess I really should be using a DataGridView, or ListView, but I wanted more than just a line of text and a small icon per row; I wanted it to look similar to the downloads view in firefox (Ctrl + J). (See screenshot)</p> <p>Thanks very much for all your input, BTW. I guess I'll have to rethink...</p> <p><a href="http://img156.imageshack.us/img156/1057/capture.png" rel="nofollow noreferrer">alt text http://img156.imageshack.us/img156/1057/capture.png</a></p>
 

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