Board index » delphi » Help with Treeviews

Help with Treeviews

Hi,

I want to use a Treeview to display a list like Outlook Expresses  mail box.
Each item is a file NOT a folder, but looks like a folder in the treeview.

The problem is I have never used a TreeView before and have no idea how to
use them.
Could someone please send me an example on how to use one?

Regards,
Nick Wiseman

 

Re:Help with Treeviews


I spent an evening playing with the Tree component in Delphi 4 the other
night. The result was not really very useful as an application, but it was a
useful exercise for me! I haven't got the drag & drop working yet, &
probably won't now, but have sent Nick the source code, in case it's any
use. Anyone else interested? (I doubt it!)

Quote
Nick Wiseman wrote in message <6u4qvn$7k...@news.mel.aone.net.au>...
>Hi,

>I want to use a Treeview to display a list like Outlook Expresses  mail
box.
>Each item is a file NOT a folder, but looks like a folder in the treeview.

>The problem is I have never used a TreeView before and have no idea how to
>use them.
>Could someone please send me an example on how to use one?

>Regards,
>Nick Wiseman

Re:Help with Treeviews


In article <6u4qvn$7k...@news.mel.aone.net.au>, "Nick Wiseman"

Quote
<nwise...@webfront.net.au> writes:
>I want to use a Treeview to display a list like Outlook Expresses  mail box.
>Each item is a file NOT a folder, but looks like a folder in the treeview.

>The problem is I have never used a TreeView before and have no idea how to
>use them.
>Could someone please send me an example on how to use one?

You have to put the different bitmaps into an TImageList (using the ImageList
Editor - double-click on the TImageList). Each bitmap has an index number.

I allocate names for the images by using const as :-

const
  {treenode image values}
  Null : integer = 0; {horizontal connecting line}
  NullDrop : integer = 8; {a line "T" for connection to next child nodes}
  X : integer = 1;   {cross-out}
  M : integer = 2;   {member}
  C : integer = 3;   {on committee}
  T : integer = 4;   {trustee}
  MT : integer = 5;  {member AND a trustee}
  CT : integer = 6;  {on committee AND a trustee}
  CM : integer = 7;  {on committee AND a member (for trustees display only)}

Then I allocate the image list indexes to the Node.ImageIndex (for normal
viewing) and the Node.SelectedImage (for when the node is selected) as in my
display of the role of a member in a small club, depending on whhat the
members' role is :-

  {set the particular icon to display}
  Node.ImageIndex := Null;  {default display no icon - just a horizontal line}
  if 'X' in MembType then
    Node.ImageIndex := X;    {not a member}
  {member has a single role . . .}
  if 'C' in MembType then
     Node.ImageIndex := C;    {on Committee}
  if 'M' in MembType then
     Node.ImageIndex := M;    {member}
  if 'T' in MembType then
    Node.ImageIndex := T;    {trustee}
  {. . .  multi role}
  if ('C' in MembType) and ('T' in MembType) then
    Node.ImageIndex := CT;   {on Committee and trustee}
  if ('M' in MembType) and ('T' in MembType) then
    Node.ImageIndex := MT;   {member and trustee}
  if ('C' in MembType) and ('M' in MembType) then
    Node.ImageIndex := CM;   {on Committee and member}
  {set the same image for display when selected}
  Node.SelectedIndex := Node.ImageIndex;

You, of course, would have only one image, but you'd have to do it in a similar
way (using an ImageList) even so..

Alan Lloyd
alangll...@aol.com

Re:Help with Treeviews


I spent an evening playing with the Tree component in Delphi 4 the other
night. The result was not really very useful as an application, but it was a
useful exercise for me! I haven't got the drag & drop working yet, &
probably won't now, but have sent Nick the source code, in case it's any
use. Anyone else interested? (I doubt it!)

Quote
Nick Wiseman wrote in message <6u4qvn$7k...@news.mel.aone.net.au>...
>Hi,

>I want to use a Treeview to display a list like Outlook Expresses  mail
box.
>Each item is a file NOT a folder, but looks like a folder in the treeview.

>The problem is I have never used a TreeView before and have no idea how to
>use them.
>Could someone please send me an example on how to use one?

>Regards,
>Nick Wiseman

Other Threads