title: Font causes GDI leak in custom control
body: <p>I have created a custom control like below.</p>
  
  <pre><code>public partial class TextBoxEx : TextBox
  {
    public TextBoxEx()
    {
      InitializeComponent();
      Font = Utility.normalFont;
    }
  
     protected override void OnPaint(PaintEventArgs pe)
     {
      base.OnPaint(pe);
     }
   }
  //A utility class to initialize font.   
  class Utility
  {
  
      internal static Font normalFont = new Font("Arial", 18);
  }
  </code></pre>
  
  <p>I have two forms Form1 and Form2. This TextBoxEx is added to Form2. I am showing Form2 when clicking a button in Form1.</p>
  
  <p>Continuously showing and closing Form2 causes GDI leak in my application. After analysing with a GDI detection tool(Bear.exe), it is found that the Font causes GDI leak.</p>
  
  <p>My question is,</p>
  
  <ol>
  <li>Why the Font is not released even though Dispose() method of TextBoxEx is get called.(While closing Form2, Dispose() method of TextBoxEx will be invoked automatically).</li>
  <li>How can I solve GDI leak caused by Font?. 
  (Font.Dispose() cannot be called in Dispose() method of TextBoxEx. Because it throws "Parameter is not valid" exception in the constructor).</li>
  </ol>