title: Windows Forms: using BackgroundImage slows down drawing of the Form's controls
body: <p>I have a Windows Form (C# .NET 3.5) with a number of buttons and other controls on it, all assigned to a topmost Panel which spans the whole Form. For example, the hierarchy is: Form -> Panel -> other controls.</p>
  
  <p>As soon as I assign a BackgroundImage to the Panel, the controls draw very slowly. I have the same effect if I use the Form's BackgroundImage property and set the Panel's BackgroundColor to "transparent". It appears as if the window with the background is drawn first, then each control is added one-by-one each with a slight delay before the next is drawn. In other words, you can actually follow the order in which each control is drawn to the Form. Once all Controls have been drawn once this effect doesn't happen anymore but the responsiveness of the Form is still slow.</p>
  
  <p>In Visual Studio's designer I get the same effect, especially noticeable when moving controls around. Sometimes the form's drawing stops completely for a second or two which makes working with BackgroundImage a total drag, both in the designer and the resulting application.</p>
  
  <p>Of course, I tried using DoubleBuffered = true, and I also set it on all controls using reflection, to no effect.</p>
  
  <p>Also, here's the forms loading code because it's a bit unusual. It copies all controls from another form onto the current form. This is done in order to be able to edit each screen's visual appearance separately using the designer while sharing a common form and common code basis. I have a hunch that it may be the cause of the slowdowns, but it still doesn't explain why the slowdowns are already noticeable in the designer.</p>
  
  <pre><code>private void LoadControls(Form form)
  {
      this.SuspendLayout();
  
      this.DoubleBuffered = true;
      EnableDoubleBuffering(this.Controls);
  
      this.BackgroundImage = form.BackgroundImage;
      this.BackColor = form.BackColor;
  
      this.Controls.Clear();
      foreach (Control c in form.Controls)
      {
          this.Controls.Add(c);
      }
  
      this.ResumeLayout();
  }
  </code></pre>
  
  <p>As you can see, <code>SuspendLayout()</code> and <code>ResumeLayout()</code> are used to avoid unnecessary redraw.</p>
  
  <p>Still, the form is "slow as hell" once a BackgroundImage is used. I even tried converting it to PNG, JPG and BMP to see if that makes any difference. Also, the image is 1024x768 in size, but smaller images have the same slowdown effect (although slightly less).</p>
  
  <p>What should I do?</p>