title: How to display FontFamily in Combobox?
body: <p>I have a combobox and I need to populate it with all the available fonts in the system - their actual name, style, etc...</p>
  
  <p>From all the information I can find online, I am able to put together the DrawItem event, but I keep running into the following error, <strong>"Cannot invoke non-delegate type 'System.Drawing.Font'"</strong> In fact, I borrowed line per line from other websites and made some changes. So, I thought it should have worked.</p>
  
  <p>Here is how I populate the items list in the ComboBox:</p>
  
  <pre><code>method MainForm.MainForm_Load(sender: System.Object; e: System.EventArgs);
  var thefont:Font;
  begin
      if (ComboBox4.Items.Count&gt;0) then
          ComboBox4.Items.Clear;
  
      for each oneFontFamily in FontFamily.Families do
      begin
          if (oneFontFamily.IsStyleAvailable(FontStyle.Regular)) then
              thefont := new Font(oneFontFamily.Name, 15)
          else if (oneFontFamily.IsStyleAvailable(FontStyle.Bold)) then
              thefont := new Font(oneFontFamily.Name, 15,FontStyle.Bold)
          else if (oneFontFamily.IsStyleAvailable(FontStyle.Italic)) then
              thefont := new Font(oneFontFamily.Name, 15,FontStyle.Italic)
          else if (oneFontFamily.IsStyleAvailable(FontStyle.Strikeout)) then
              thefont := new Font(oneFontFamily.Name, 15, FontStyle.Strikeout)
          else if (oneFontFamily.isStyleAvailable(FontStyle.Underline)) then
              thefont := new Font(oneFontFamily.Name, 15, FontStyle.Underline);
  
      if (thefont &lt;&gt; nil) then
          ComboBox4.Items.Add(theFont);
          end;
  end;
  </code></pre>
  
  <p>Here is the combobox4 drawitem event:</p>
  
  <pre><code>method MainForm.comboBox4_DrawItem(sender: System.Object; e: System.Windows.Forms.DrawItemEventArgs);
  begin
      if e.index = -1 then exit;
  
      // Draw the background of the item
      e.DrawBackground();
  
      // Should we draw the focus rectangle
      if ((e.State and DrawItemState.Focus) &lt;&gt; DrawItemState.Checked) then
          e.DrawFocusRectangle();
  
          // Create a new background brush.
          var b := new SolidBrush(e.ForeColor);
  
          // Draw the item.
          // This line raises the above mentioned error.
          e.Graphics.DrawString(FontFamily(comboBox4.Items[e.Index]).Name, font(comboBox4.Items[e.Index]), b, e.Bounds.x,e.Bounds.y);  &lt;&lt;===== Here is where the error is raised
  end;
  </code></pre>
  
  <p><strong>UPDATED:</strong>
  I modified the line that was causing the error and it compiles without error now but as I stated in my comment it is not drawing the fonts in their own style and size.</p>
  
  <pre><code>e.Graphics.DrawString(FontFamily(comboBox4.Items[e.Index]).Name, new font((comboBox4.Items[e.Index] as Font), (comboBox4.Items[e.Index] as Font).Style), b, e.Bounds.x,e.Bounds.y);
  </code></pre>
  
  <p><strong>UPDATE:</strong> I forgot to set the DrawMode to OwnerDrawFixed. Now it is calling my DrawItem Event but still not drawing the Fonts in their own style and sizes. </p>
  
  <p>I want the combobox to look like the following image:</p>
  
  <p><img src="https://i.stack.imgur.com/u0v4h.png" alt="someone else&#39;s combobox"></p>
  
  <p>Not like mine below:</p>
  
  <p><img src="https://i.stack.imgur.com/CWKim.png" alt="actual Image of the winform with combobox"></p>