[DUG] Soft-Gems Virtual TreeView for a ListView

Conor Boyd Conor.Boyd at trimble.co.nz
Mon Nov 12 16:06:20 NZDT 2007


The Header property of TVirtualStringTree has a Columns property.
Specify your columns in there.
 
Then the OnGetText event has a Column parameter.
 
So you can do something like this in your OnGetText event handler:
 
procedure TFileSelectionDialog.vstFilesGetText(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
  var CellText: WideString);
var
  NodeData : PTreeViewNodeData;
begin
  NodeData := Sender.GetNodeData(Node);
 
  CellText := '';
 
  case Column of
    0:  CellText := ExtractFileName(NodeData.Filename);
    1:  begin
          if not NodeData.IsFolder then
            CellText := DateTimeToStr(NodeData.FileDate);
        end;
  end;
end;

This is from when I wrote our own file selection dialog, since the
built-in Delphi one can't cope with more than a certain number of files
(if you're interested in the specifics, IIRC the number of files the
built-in one can cope with is limited to the number of fully qualified
paths which will fit into 32000 bytes or something - it's a problem with
the underlying WinAPI).
 
Hopefully that's enough to get you going.  Ask away if you've got more
questions.
 
HTH,
 
Conor

________________________________

From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Ross Levis
 
I think someone mention they were using Virtual TreeView recently.  I
heard that it can be made to look like a standard ListView, so I'm
investigating it to replace a TListView in an app of mine which takes
far too long to load up to 20,000 items.

 

I can't use TListView in virtual mode as it seems way too difficult to
enable sorting on columns which I need.  The Virtual TreeView appears to
handle sorting as easy as TListView does in non-virtual mode.

 

I'm just having difficultly working out how the use the component!  I
realize I need to set up a record for each set of data but I can't work
out how to add columns of data.  The examples are mostly involved with
tree structures.

 

I'm hoping someone can quote for me a basic piece of code for adding say
2 items with 2 or 3 columns.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.adventureeducation.co.nz/pipermail/delphi/attachments/20071112/6e000054/attachment.html


More information about the Delphi mailing list