Solved

Windows Explorer Effect

Posted on 2010-11-16
9
288 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 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