title: Why is ListBox flickering when DrawItem event executes?
body: <p>I have a ListBox and it has a DrawItem event defined as follows. The ListBox's following properties are set as such - DrawMode = OwnerDrawFixed and FormattingEnabled = ture. </p>
  
  <p>When I run the program and add more than one item or object to the ListBox, it flickers really bad. I am not sure what exactly is the problem. I have ListBoxes with a very similar setup on other winforms and they don't flicker. I try to capture an image of the winform with the flickering ListBox, but the captured image didn't show the ListBox flickering every time.</p>
  
  <pre><code>method HTrendFrm.AGroupList_DrawItem(sender: System.Object; e: System.Windows.Forms.DrawItemEventArgs);
      var
        lb:ListBox;
        tg:TTrendGroup;
      begin
        if e.Index = -1 then exit;
        lb := (sender as ListBox);
        tg := TTrendGroup(LoggingGroup.Item[e.Index]);
        if tg.Enabled then
        begin
          if ((e.State and DrawItemState.Selected) = DrawItemState.Selected) then
          begin
            lb.ForeColor:=Color.White;
            e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
          end
          else
           lb.ForeColor := Color.Black;
        end
        else
           lb.ForeColor := Color.LightGray;
  
        lb.CreateGraphics.DrawString(tg.name,new Font('Arial',9,FontStyle.Bold),new SolidBrush(lb.ForeColor),e.Bounds.Left+5,e.Bounds.Top);
  
          if ((e.State and DrawItemState.Focus) &lt;&gt; DrawItemState.Checked) then
              e.DrawFocusRectangle();
      end;
  </code></pre>
  
  <p>So, what is causing my ListBox Flicker?</p>
  
  <p>Thanks in advance,</p>