title: Graphics DrawString to Exactly Place Text on a System.Label
body: <p>I have overridden the <a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.control.onpaint.aspx" rel="nofollow noreferrer">OnPaint</a> method of my <a href="https://msdn.microsoft.com/en-us/library/system.windows.controls.label.label.aspx" rel="nofollow noreferrer">Label</a> control in VS2008:</p>
  
  <pre><code>void Label_OnPaint(object sender, PaintEventArgs e) {
    base.OnPaint(e);
    dim lbl = sender as Label;
    if (lbl != null) {
      string Text = lbl.Text;
      e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
      if (myShowShadow) { // draw the shadow first!
        e.Graphics.DrawString(Text, lbl.Font, new SolidBrush(myShadowColor), myShadowOffset, StringFormat.GenericDefault);
      }
      e.Graphics.DrawString(Text, lbl.Font, new SolidBrush(lbl.ForeColor), 0, 0, StringFormat.GenericDefault);
    }
  }
  </code></pre>
  
  <p>This works, but I really want to find out how to center the text both vertically and horizontally. I've heard of the <code>MeasureString()</code> method, but my "Text" complicates matters because it could include page breaks.</p>
  
  <p>Could someone guide me with how to do this?</p>