title: Making a master-detail view with a header bar per item group in a Virtual Treeview (TVirtualStringTree)
body: <p>I am trying to get a result that looks like this out of TVirtualStringTree:</p>
  
  <p><img src="https://i.stack.imgur.com/AaJPe.png" alt="desired virtualtreeview appearance"></p>
  
  <p>I believe that it might be possible either directly with <code>TVirtualStringTree</code> (the main Virtual Treeview control by Mike Lischke), or by subclassing it and modifying the inherited control, or by going to a <code>TVirtualDrawTree</code>.</p>
  
  <p>Here is what I can get, and shows the problem that I face:</p>
  
  <p><img src="https://i.stack.imgur.com/1vq4r.png" alt="actual vritualtreeview appearance"></p>
  
  <p>The problem I have is that  I can't seem to get the text for column 0 to take up the entire horizontal area of the virtual treeview control. There is a virtual treeview demo in the Advanced demo showing multiline text that appears to do what I need, but I am unable to figure out how to apply it in combination with the detail columns that I need below the header row (shown as Node,Node,Node in the picture).</p>
  
  <p>Here is what I tried:</p>
  
  <ul>
  <li>Modify ContentRect.Right in BeforeCellPaint event:</li>
  <li>set <code>toGridExtensions</code> on in <code>TreeOptions.MiscOptions</code>.</li>
  </ul>
  
  <p>Here is a code sample showing  how I tried to change the contentRect:</p>
  
  <pre><code>procedure TForm1.VirtualStringTree1BeforeCellPaint(Sender: TBaseVirtualTree;
    TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
    CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
  var
     level:Integer;
  begin
   level := VirtualStringTree1.GetNodeLevel(Node);
   if (level=0) then
      Inc( ContentRect.Right, 300);
  
  end;
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>Using the answer accepted below, I get the following:</p>
  
  <p><img src="https://i.stack.imgur.com/v3vd5.png" alt="enter image description here"></p>