Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add properties to treeview
Message
De
14/11/2007 20:30:25
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01268950
Message ID:
01269045
Vues:
16
>>hi
>>There exists a way of being able to add a property to every node of this control
>>
>>As for example thisform.addpropety ("mypropety")
>
>No.
>But if you subclass TreeView in some container, you could add a property to that class based on collection. Then in That collection you could Add whatever you need and use node key as key in that collection.
>Here an example:

Aren't you reusing the same oEmpty for all nodes? I'd rather create it inside the loop and discard it while still in the loop - the reference in the collection would stay.

>
>oForm = NEWOBJECT([Form1])
>oForm.Show(1)
>
>
>**************************************************
>*-- Form:         form1 (d:\test\test.scx)
>*-- ParentClass:  form
>*-- BaseClass:    form
>*-- Time Stamp:   11/14/07 09:28:04 PM
>*
>DEFINE CLASS form1 AS form
>
>
>    Top = 0
>    Left = 0
>    Height = 253
>    Width = 475
>    DoCreate = .T.
>    Caption = "Form1"
>    mynodeproperties = .F.
>    Name = "Form1"
>
>
>    ADD OBJECT oletree AS olecontrol WITH ;
>        Top = 1, ;
>        Left = 24, ;
>        Height = 240, ;
>        Width = 334, ;
>        Name = "oleTree",;
>        oleClass=[MSComctlLib.TreeCtrl.2]
>
>
>    ADD OBJECT text1 AS textbox WITH ;
>        Height = 23, ;
>        Left = 370, ;
>        Top = 4, ;
>        Width = 100, ;
>        Name = "Text1"
>
>
>    ADD OBJECT text2 AS textbox WITH ;
>        Height = 23, ;
>        Left = 370, ;
>        Top = 37, ;
>        Width = 100, ;
>        Name = "Text2"
>
>
>    ADD OBJECT text3 AS textbox WITH ;
>        Height = 23, ;
>        Left = 370, ;
>        Top = 67, ;
>        Width = 100, ;
>        Name = "Text3"
>
>
>    PROCEDURE filltree
>        LPARAMETERS lnParentKey
>        LOCAL lnRecNo, oEmpty AS EMPTY
>        oEmpty = NEWOBJECT([EMPTY])
>        ADDPROPERTY(oEmpty,[NodeText]  ,[])
>        ADDPROPERTY(oEmpty,[NodeKey]   ,0)
>        ADDPROPERTY(oEmpty,[Something] ,[])
>        IF VARTYPE(lnParentKey) == [L]
>           thisform.myNodeProperties = NEWOBJECT([Collection])
>           SEEK 0 IN crsTest
>           SCAN WHILE Parent = 0
>                lnRecNo  = RECNO()
>                thisform.oleTree.Nodes.Add(,1,TRANSFORM(Key)+[_],Text)
>                oEmpty.NodeText = Text
>                oEmpty.NodeKey  = Key
>                oEmpty.Something = SYS(2015)
>                thisform.myNodeProperties.Add(oEmpty,TRANSFORM(Key)+[_])
>                thisform.FillTree(Key)
>                GOTO lnRecNo
>           ENDSCAN
>        ELSE
>           SEEK lnParentKey IN crsTest
>           SCAN WHILE Parent = lnParentKey
>                lnRecNo  = RECNO()
>                thisform.oleTree.Nodes.Add(TRANSFORM(Parent)+[_],4,TRANSFORM(Key)+[_],Text)
>                oEmpty.NodeText = Text
>                oEmpty.NodeKey  = Key
>                oEmpty.Something = SYS(2015)
>                thisform.myNodeProperties.Add(oEmpty,TRANSFORM(Key)+[_])
>                thisform.FillTree(Key)
>                GOTO lnRecNo
>           ENDSCAN
>        ENDIF
>    ENDPROC
>
>
>    PROCEDURE Load
>        CREATE CURSOR crsTest (Key I, Parent I, Text varchar(100))
>        INSERT INTO crsTest VALUES(1,0, 'root text')
>        INSERT INTO crsTest VALUES(2,1, 'child text 1')
>        INSERT INTO crsTest VALUES(3,1, 'child text 2')
>        INSERT INTO crsTest VALUES(4,2, 'grandchild text 1')
>        INDEX ON Parent TAG crsTest
>    ENDPROC
>
>
>    PROCEDURE Init
>        thisform.FillTree()
>    ENDPROC
>
>
>    PROCEDURE oletree.NodeClick
>        *** ActiveX Control Event ***
>        LPARAMETERS node
>        thisform.Text1.Value = thisform.mynodeproperties.Item(node.Key).NodeText
>        thisform.Text2.Value = thisform.mynodeproperties.Item(node.Key).NodeKey
>        thisform.Text3.Value = thisform.mynodeproperties.Item(node.Key).Something
>    ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: form1
>**************************************************
>

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform