title: C# graphics, paint, picturebox centering
body: <p>Ok, so this is the problem: in C# forms I've created a new private void:</p>
  
  <pre><code>private void NewBtn(string Name, int x, int y)
  </code></pre>
  
  <p>Which has a purpose of creating a picturebox that imitates behavior of a button (don't ask why, I simply enjoy complicating things) and can be called as many times as I want.</p>
  
  <pre><code>Font btnFont = new Font("Tahoma", 16);
  PictureBox S = new PictureBox();
  S.Location = new System.Drawing.Point(x, y);
  S.Paint += new PaintEventHandler((sender, e) =&gt;
  {
      e.Graphics.TextRenderingHint = 
          System.Drawing.Text.TextRenderingHint.AntiAlias;
      e.Graphics.DrawString(Name, btnFont, Brushes.Black, 0, 0);
  });
  Controls.Add(S);
  </code></pre>
  
  <p>Now, I am worried about part with Paint/Graphics (ignore rest of the code, I only gave some of it). I want to center the text that I write as "Name" in void when I call it "NewBtn(Name, x, y)". So, what should I put as </p>
  
  <pre><code>e.Graphics.DrawString(Name, btnFont, Brushes.Black, ThisX???, 0);
  </code></pre>
  
  <p>Suggestions?</p>