Solved

Windows Explorer Effect

Posted on 2010-11-16
9
284 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now