Solved

Windows Explorer Effect

Posted on 2010-11-16
9
285 Views
Last Modified: 2012-05-10
Hi,

I need to show data in format like Windows Explorer 'Folders' and 'Files'
The input data will be from a database in heirarchial  pattern.

Regards
Allan
0
Comment
Question by:Allan_Fernandes
  • 5
  • 4
9 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 34143902
A bit unclear to me, do you mean the data will be extracted in a temp folder and you want to view it as the explorer does ?
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34143941
Could you provide more details please, do you mean you will get the hierarchy of the Files and Folders from the database and you want to have expand sign [+] next to the folders and once clicked it shows the content (again files and folders) and if a file is clicked it will be opened with the default or associate application, is that it ?
0
 

Author Comment

by:Allan_Fernandes
ID: 34143964

>> from the database and you want to have expand sign [+] next to the folders and once clicked it shows >> the content (again files and folders) and if a file is clicked it will be opened with the default or >> associate application, is that it ?


You have understood correct.
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 24

Expert Comment

by:jimyX
ID: 34143994
How is your data formatted in the database ? Please provide sample of data from the database just to know in which form you are storing it.
0
 

Author Comment

by:Allan_Fernandes
ID: 34144274
Sample database format

ParentCode   ItemCode    Name
0                    1                Birds
1                    10              Parrot                  
1                    11              Piegon
1                    12              Eagle
12                  100            Falcon
12                  101            Hawk

Regards
Allan
0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 34144317
OK, below is how it will look, but what's next ? for example what shall happen when Parrot is clicked and/or double clicked ?

0
|
----1 Birds
      |
      ------- 10 Parrot
      |
      ------- 11 Piegon
      |
      ------- 12 Eagle
                  |
                  ------- 100 Falcon
                  |
                  ------- 101 Hawk
0
 

Author Comment

by:Allan_Fernandes
ID: 34144488
Thanks for helping me clarify my needs. Please advice if ready component.

I can use Treeview for Left Panel and Check list box in a Right Hand Panel

>> If selection is on Eagle then

 ---1 Birds                               |               100 Falcon
      |                                        |               101 Hawk
      ------- 10 Parrot                |
      |
      ------- 11 Piegon
      |
      ------- 12 Eagle

Thanks
Allan
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34146527
Allan,
Be careful, you should be assigning the points after you are given the final solution and it met your demand. Anyway, back to your question:

You can still add all the numbers in the Treeview as a hierarchy in addition to viewing the ItemCodes, if available, in a checklistbox. Please let me know if this is what you wanted:

Procedure TVAddChild(ParnetCode, Str:string);
var
  i : integer;
  s1, s2:string;
begin
  for i := 0 to Form1.Treeview1.Items.Count-1 do
    begin
      s1 := Form1.Treeview1.Items[i].Text;
      if pos(' ',s1) <= 0 then
        begin
          if s1 = ParnetCode then
             begin
               Form1.Treeview1.Items[i].Selected := True;
               Form1.Treeview1.Items.AddChild(Form1.Treeview1.Selected, Str);
               break;
           end;
        end
      else
        begin
          s2 := copy(s1,1,pos(' ',s1)-1);
          if s2 = ParnetCode then
             begin
              Form1.Treeview1.Items[i].Selected := True;
              Form1.Treeview1.Items.AddChild(Form1.Treeview1.Selected, Str);
              break;
            end;
        end;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i : integer;
begin
  Query1.Close;
  Query1.SQL.Text := 'select min(ParentCode) as root from Table1';
  Query1.Open;
  Treeview1.Items.Clear;
  Treeview1.Items.Insert(Treeview1.Items.GetFirstNode,Query1.fieldbyname('root').AsString);
  Query1.Close;
  Query1.SQL.Text := 'select * from Table1 order by ParentCode';
  Query1.Open;
  Query1.First;
  for i:= 0 to Query1.RecordCount-1 do
    begin
      TVAddChild(Query1.fieldbyname('ParentCode').AsString, Query1.fieldbyname('ItemCode').AsString +' '+ Query1.fieldbyname('Name').AsString);
      Query1.Next;
    end;
  Treeview1.Items[0].Selected := true;
  Query1.Close;
end;

procedure TForm1.Treeview1Click(Sender: TObject);
var
  i : integer;
  s1, s2 : string;
begin
  Query1.Close;
  s1 := Treeview1.Selected.Text;
  if pos(' ',s1) <= 0 then
    begin
      Query1.SQL.Text := 'select * from Login where ParentCode = ' + QuotedStr(S1);
    end
  else
    begin
      s2 := copy(s1,1,pos(' ',s1)-1);
      Query1.SQL.Text := 'select * from Login where ParentCode = ' + QuotedStr(s2);
    end;
  Query1.Open;
  Checklistbox1.Clear;
  for i := 0 to Query1.RecordCount-1 do
    begin
      Checklistbox1.Items.Add(Query1.fieldbyname('ItemCode').AsString +' '+ Query1.fieldbyname('Name').AsString);
      Query1.Next;
    end;
  Query1.Close;
end;

Open in new window

0
 

Author Comment

by:Allan_Fernandes
ID: 34162901
Thanks This is perfect
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 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