Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Populate a Treeview
Message
From
10/03/2000 06:33:38
 
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00343015
Message ID:
00344085
Views:
19
Hi Pete,

I to struggled with this.

Look at the sample that came with VFP...

You need to have an imageslist on your form to hold the images.
To populate the tree I add the nodes from a cursor that has the records selected in the order that I want them displayed.

Then when you click on a node you can show that record in a pageframe without tabs with the top page being a cover.. I do a popup menu on left click to delete, edit or add as approprate.

Some code example from one of my forms
WITH This
  * Add the Root Node for Projects
  .oleTreeview.Nodes.Clear()
  lcKey = "_RP"
  lcText = "Projects"
  .oleTreeview.Nodes.Add(,,lcKey ,lcText ,lcImage ,lcSelectedImage)

  IF RECCOUNT("tmpPjt") > 0
    * Add any Projects
    GOTO TOP IN tmpPjt
    SELECT tmpPjt
    DO WHILE NOT EOF()
      lcRelative = "_RP"
      lnRelationship = 4
      lcKey = "PJT" + ALLTRIM(STR(tmpPjt.PjtId))
      lcText = ALLTRIM(tmpPjt.PjtName)
      lcImage = "Pjt"
      lcSelectedImage = "Check"
      loLastPjt = .oleTreeview.Nodes.Add(lcRelative, ;
        lnRelationship, lcKey ,lcText ,lcImage ,lcSelectedImage)

      * Find any Catagories
      SELECT *;
        FROM Catagory;
        WHERE Catagory.PjtId = VAL(SUBSTR(loLastPjt.Key, 4));
        ORDER BY Catagory.CatName;
        INTO CURSOR tmpCat

      SELECT tmpCat

      DO WHILE NOT EOF()
        lcRelative = loLastPjt.Key
        lnRelationship = 4
        lcKey = "CAT" + ALLTRIM(STR(tmpCat.CatId))
        lcText = ALLTRIM(tmpCat.CatName)
        lcImage = "Bridge"
        lcSelectedImage = "Check"
        loLastCat=.oleTreeview.Nodes.Add(lcRelative, ;
          lnRelationship, lcKey ,lcText ,lcImage ,lcSelectedImage)

        SELECT tmpCat
        SKIP IN tmpCat
      ENDDO
      SELECT tmpPjt
      SKIP IN tmpPjt
    ENDDO
  ENDIF

In the treeview MouseDown
IF nButton = 2
  ThisForm.lRightMouse = .t.
ELSE
  ThisForm.lRightMouse = .f.
ENDIF

In the treeview NodeClick
IF ThisForm.lRightMouse = .T.
	DO PjtMenu.mpr WITH ThisForm
	ThisForm.lRightMouse = .F.
ENDIF

In the Form Init
This.oleTreeview.ImageList = This.oleImagesList
>Hello Gang,
>has anyone got any sample code which illustrates how to populate a treeview control from two tables, based on the customer/orders scenario?, basically show customer one, click on plus sign, show orders, click on customer two, show orders etc...
>
>Cheers
>
>Pete Kane
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform