title: Custom draw ListBox items with a panel
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/513229/delphi-control-that-could-mimic-add-onsextension-list-of-firefox">Delphi control that could mimic &ldquo;Add-ons|Extension list&rdquo; of Firefox?</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to make a custom ListBox control. It could look like Firefox downloads</p>
  
  <p><img src="https://i.stack.imgur.com/HKeAx.png" alt="Firefox downloads example"></p>
  
  <p>but instead of hardcoding custom drawing for any particular layout, i would like to allow the layout to be defined separately.
  Let me explain, the listbox would have a published property Layout: TWinControl
  The idea is to design a layout in a say panel, so for the example above it would look something like:</p>
  
  <p><img src="https://i.stack.imgur.com/B1xPF.png" alt="Panel with a row layout"></p>
  
  <p>Then in customdraw of the ListBox it would use panel's painting. Of course, each row would draw the data for corresponding item. So the controls would be DbAware and recordIndex would be adjusted for each draw. (I don't really use DBAware controls, I use custom data bindings, but it's the same principle)</p>
  
  <p>Has anyone already done something like this ? Think it's a good/bad idea ?</p>
  
  <p>I have started writing a test app and will edit this question to add specific implementation questions, </p>
  
  <p>I am hoping to use only 1 instance of the panel for all rows, it should not be visible on it's own outside of the listbox.</p>
  
  <p>So far I tried using <code>Panel.PaintTo()</code> in the ListBox <code>OnDrawItem</code>, it basically works, but only if Panel is parented and visible elsewhere on the form.
  Can I make the panel invisible yet still use it's painting ?
  How would you go about implementing this ?</p>