Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Some problem with VirtualTreeView and paths

Posted on 2004-04-01
9
Medium Priority
?
321 Views
Last Modified: 2010-04-05
Hi!
I'm using Virtual TreeView from http://virtualtreeview.delphi-gems.com/VT.php.
The problem is that I have a database that has a table with 3 fields volume, path and filename.
I want to list each recordset from a query in the virtualtreeview with the volume as root and the filename as the last childnode and the path as nodes between those two and
do that for each filename in the table.
I have tried 2 different approaches with no success. :(
Can anyone give me a good solution how to do this ??

Regards,
  Tomas Helgi
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 10736998
Place on a Form
    vsTree: TVirtualStringTree;
    Button1: TButton;
    Edit1: TEdit;            // for volume text
    Edit2: TEdit;            // for path text
    Edit3: TEdit;            // for file text
-------------------------------------------------
I don't checked for identical triples volume,path,file
-------------------------------------------------

type
  PMyRec = ^TMyRec;
  TMyRec = record
    Caption: WideString;
  end;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  vsTree.NodeDataSize := SizeOf(TMyRec);
  Edit1.Text := 'Volume';
  Edit2.Text := 'Path';
  Edit3.Text := 'File';
end;

procedure TForm1.vsTreeGetText(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType;
  var CellText: WideString);
var
  Data: PMyRec;
begin
  Data := Sender.GetNodeData(Node);
  if Assigned(Data) then
    begin
    CellText := Data.Caption;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  pvn: PVirtualNode;
  pvnVol: PVirtualNode;
  Data: PMyRec;
  FoundVolume: boolean;
  FoundPath: boolean;
begin
  FoundVolume := False;
  FoundPath := False;
  pvn := vsTree.GetFirst;
  while pvn <> nil do
    begin
    Data := vsTree.GetNodeData(pvn);
    if Data.Caption = Edit1.Text then
      begin
      FoundVolume := True;
      pvnVol := pvn;
      pvn := vsTree.GetFirstChild(pvn);
      while pvn <> nil do
        begin
        Data := vsTree.GetNodeData(pvn);
        if Data.Caption = Edit2.Text then
          begin
          FoundPath := True;
          break;
          end;
        pvn := vsTree.GetNextSibling(pvn);
        end;
      break;
      end;
    pvn := vsTree.GetNextSibling(pvn);
    end;
  if not FoundVolume then
    begin
    vsTree.RootNodeCount := vsTree.RootNodeCount + 1;
    pvn := vsTree.GetLast;
    Data := vsTree.GetNodeData(pvn);
    Data.Caption := Edit1.Text;

    pvn := vsTree.AddChild(pvn);
    Data := vsTree.GetNodeData(pvn);
    Data.Caption := Edit2.Text;
    pvn := vsTree.AddChild(pvn);
    Data := vsTree.GetNodeData(pvn);
    Data.Caption := Edit3.Text;
    end
  else if not FoundPath then
    begin
    pvn := vsTree.AddChild(pvnVol);
    Data := vsTree.GetNodeData(pvn);
    Data.Caption := Edit2.Text;
    pvn := vsTree.AddChild(pvn);
    Data := vsTree.GetNodeData(pvn);
    Data.Caption := Edit3.Text;
    end
  else
    begin
    pvn := vsTree.AddChild(pvn);
    Data := vsTree.GetNodeData(pvn);
    Data.Caption := Edit3.Text;
    end;
end;

0
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 1600 total points
ID: 10738568
there's a DB aware version of VTV in the Addons package (same page as the main distro of VTV)
try that .. it worked fine a year ago :-)
0
 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 10744177
Thank you very much Lee Nover for pointing me in the right direction.
The DB aware version and it's functionality is what I was looking for.

Regards,
   Tomas Helgi
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 10744902
Just one more question.
I'm little bit confused what the PathField stands for and how it fits into the picture.

Regards,
   Tomas Helgi
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10754900
it's for parent/child relations in the Tree
you can have a field that stores 'c:\folder1\folder2\file1' .. the tree would then have a root node of 'c:' and a child 'folder1' with a child 'folder2' ... and so on :)
0
 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 10755686
Great ;)
Thank you very much.

Regards,
   Tomas Helgi
0
 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 10759111
Hmmm ok I have changed the parameters to dboPathStructure and set the PathField but I don't get any data in the Tree.
What do I have to do to make it visible (besides Opening the table ;) ???

Regards,
  Tomas Helgi
0
 
LVL 25

Author Comment

by:Tomas Helgi Johannsson
ID: 10772949
Lee
Could you give me an example on how to configure the Tree and program around it so that this would work.
I don't seem to be doing it right.

Best regards,
  Tomas Helgi
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 10773435
sorry I misslead you .. the Path in the PathFieldName must have integers joined with a period (dot)
the path represents the nodes relation thru KeyFieldName

the current version of the DBTree supports only integer and floating point values for KeyField and ParentField
it should be fairly simple to change the ID from Double to String
5-10 mins of work .. maybe if I have a bit more time I can make that change
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question