title: .NET Multiline TextBox - Set number of lines
body: <p>I want to be able to set the number of lines in a multilined <code>TextBox</code>.</p>
  
  <p>I've tried the following:</p>
  
  <pre><code>int initHeight = textBox1.Height;
  textBox1.Height = initHeight * numOfLines;
  </code></pre>
  
  <p>But this makes it too large when <code>numOfLines</code> gets large. So then I tried this:</p>
  
  <pre><code>float fontHeight = textBox1.CreateGraphics().MeasureString("W", textBox1.Font).Height;
  textBox1.Height = fontHeight * numOfLines;
  </code></pre>
  
  <p>But this was too small when <code>numOfLines</code> was small, and too large when <code>numOfLines</code> was large.</p>
  
  <p>So I'm doing SOMETHING wrong... any ideas?</p>