title: Possible bug with Graphics.DrawString and TextRenderingHint in .Net Winforms
body: <p>Here's the OnPaint method of a control that simply inherits from control and provides a property to get/set the textrenderinghint:</p>
  
  <pre><code> Private _mode as TextRenderingHint = SystemDefault.
   Public Property Mode as TextRenderingHint
      Get &amp; Set _mode
   ...
  
   Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
      Dim g = e.Graphics
      Dim savMode = g.Save
      g.TextRenderingHint = Me._mode
      g.DrawString(Me.Text, Me.Font, Brushes.Black, 0, 0)
      g.Restore(savMode)
      MyBase.OnPaint(e)
   End Sub
  </code></pre>
  
  <p>Now, if you place two of these on a form, leave the first as default and change the second to AntiAlias, it looks fine at design-time but when you run the app, the first label's rendering mode has changed. Its as if the DrawString method has changed the systemdefault.</p>
  
  <p>Here's some observations:</p>
  
  <p>(1) If I explicity set the first control's mode to ClearTypeGridFit, which is the same as the default in my case, it fixes the problem. </p>
  
  <p>(2) If you place a third control on the form and leave at the default mode, it fixes the problem.</p>
  
  <p>(3) TextRenderer.DrawText doesn't replicate the problem.  </p>
  
  <p>(4) If I inherit label control and override the onpaint method to set the rendering mode, the problem is not replicated even though I set UseCompatibleTextRendering - which forces the label to render with DrawString instead of DrawText.</p>
  
  <p>I'm on XP with cleartype enabled and using visual studio 2008 express edition.</p>
  
  <p>ETA: I've tried it in C# and the same thing happens</p>