title: C#: Changing Button BackColor has no effect
body: <p>I'm having a problem with C# buttons in Windows Forms.</p>
  
  <p>I've create a number of buttons programmatically and add them to a form afterwards.</p>
  
  <p>Interestingly, every modification to those buttons (location and size) except for the modification of the <code>BackColor</code> is readily executed. Only the button's color remains unchanged.</p>
  
  <p>The code looks something like this:</p>
  
  <pre><code>public class SimpleSortAlgDisplayer : ISortAlgDisplayer
  {
  
      #region ISortAlgDisplayer Member
  
      void ISortAlgDisplayer.Init(int[] Data)
      {
          this.DataLength = Data.Length;
          this.DispWin = new CurrentSortStateWin();
          this.DispWin.Show();
          this.DispWin.Size = new Size(60 + (10 * this.DataLength), 120);
  
          this.myArrayElements = new Button[this.DataLength];
          for (int i = 0; i &lt; this.DataLength; i++)
          {
              this.myArrayElements[i] = new Button();
              //begin of series of invoked actions
  
              this.myArrayElements[i].Size=new Size(5,(int)(((80)*(double)Data[i])/1000));
              this.myArrayElements[i].Location = new Point(30 + (i * 10), 90-(this.myArrayElements[i].Size.Height));
              this.myArrayElements[i].Enabled = true;
              this.myArrayElements[i].BackColor = Color.MidnightBlue;
              this.myArrayElements[i].UseVisualStyleBackColor = true;
              this.DispWin.Controls.Add(this.myArrayElements[i]);
              this.myArrayElements[i].Refresh();
  
          }
      }
  </code></pre>
  
  <p>Ideas anyone? </p>
  
  <p>A similar question was asked <a href="https://stackoverflow.com/questions/2210246/c-background-color-problem">here</a> but the answers to it were not very helpful:</p>
  
  <ul>
  <li>Trying to use <code>Invoke</code> gives me the run-time error that <code>DispWin</code> is not yet created. </li>
  <li>Setting <code>UseVisualStyleBackColor</code> to false changes nothing. </li>
  <li>Setting <code>BackColor</code> and <code>ForeColor</code> or Showing <code>DispWin</code> only after adding and formatting the Buttons also had no effect.</li>
  </ul>
  
  <p>Where am I going wrong?</p>