title: Use parameter passed to form constructor in CreateParams in WinForms.NET
body: <p>I have a custom form defined like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>internal class DropDownForm : System.Windows.Forms.Form
  {
      public DropDownForm(bool needShadow)
      { ... }
  }
  </code></pre>
  
  <p>I need to enable form shadow depending on the needShadow parameter passed to the form constructor in the overridden CreateParams member - something like this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>protected override CreateParams CreateParams
  {
      get
      {
          CreateParams cp = base.CreateParams;
  
          if (needShadow)
              cp.ClassStyle |= CS_DROPSHADOW;
  
          return cp;
      }
  }
  </code></pre>
  
  <p>The problem is that I can't access the <code>needShadow</code> parameter passed to the <em>form constructor</em> in this <code>CreateParams</code>. The <code>CreateParams</code> member is <em>executed before the first statement</em> in my custom form <em>constructor</em>, and I can't cache the <code>needShadow</code> value passed to the form constructor in a form field to use it later in <code>CreateParams</code>.</p>
  
  <p>To solve the problem, I could turn this <code>needShadow</code> parameter into a <em>static property</em> of my form, set it before form creation and use this value in the overridden <code>CreateParams</code>. But obviously it is <em>not a good way</em> as my app can create several instances of this form, each with its own <code>needShadow</code> value.</p>
  
  <p>Is there a neat solution to this problem in WinForms .NET?</p>