title: Referencing non-static fields from static functions and vice versa impossible?
body: <p>I want to programmatically determine the space I've got for some controls I want to create dynamically. So, I want to get the container's height and divide it by the number of rows (a constant).</p>
  
  <p>I've got this function (this code is part of the form on which the panel named dynamicPanel lives):</p>
  
  <pre><code>private static int getControlHeightToUse() {
    return (dynamicPanel.Height / NUMBER_OF_ROWS);
  }
  </code></pre>
  
  <p>...which gives me the compile-time error, "*An object reference is required for the non-static field, method, or property RememberNextGen_CRLogins.CRLoginsMainForm.dynamicPanel'*"</p>
  
  <p>I don't understand what it's trying to tell me/what it wants.</p>
  
  <p>If I remove the "static":</p>
  
  <pre><code>private int getControlHeightToUse() {
    return (dynamicPanel.Height / NUMBER_OF_ROWS);
  }
  </code></pre>
  
  <p>...I then get the compile-time error, "*A field initializer cannot reference the non-static field, method, or property 'TitanNextGen_CRLogins.CRLoginsMainForm.getControlHeightToUse()'*"</p>
  
  <p>...on the indicated line below:</p>
  
  <pre><code>public partial class CRLoginsMainForm : Form {
  
    int controlHeight = getControlHeightToUse(); // &lt;-- err
  </code></pre>