Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with a code
Message
 
À
07/05/2007 11:16:50
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01223049
Message ID:
01223123
Vues:
24
This message has been marked as the solution to the initial question of the thread.
Try:
oForm = CREATEOBJECT([Form1])
oForm.Show(1)


**************************************************
*-- Form:         form1 (f:\program files\microsoft visual foxpro 9\test.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   05/07/07 08:18:08 PM
*
DEFINE CLASS form1 AS form


    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 223, ;
        Left = 330, ;
        Height = 27, ;
        Width = 33, ;
        Caption = "Click", ;
        Name = "Command1"


    PROCEDURE addchilds
        LPARAMETERS lnParent
        LOCAL lnRecNo
        IF SEEK(BINTOC(lnParent), "crsHorses", "crsHorses")
          SCAN WHILE crsHorses.Parent = lnParent
            *** Add the child node to the tree
            lnRecNo  = RECNO([crsHorses])
            lcNodeKey = [P] + TRANSFORM( crsHorses.idn )
            lcNodeText = ALLTRIM( crsHorses.Name)
            lcParentKey = [P] + ALLTRIM(TRANSFORM( Parent)) 
            Thisform.Tree1.Nodes.Add( lcParentKey, 4 , lcNodeKey, lcNodeText )     
            thisform.AddChilds(crsHorses.idn)
            GOTO lnRecNo IN crsHorses
          ENDSCAN
          Thisform.Tree1.Nodes( lcParentKey ).Expanded = .T.        
        ENDIF
    ENDPROC


    PROCEDURE Init
        CREATE CURSOR crsHorses (Idn int, Parent int, Name char(30), Gender char(20))
        INSERT INTO crsHorses VALUES (1,3,[Silver],[Horse])
        INSERT INTO crsHorses VALUES (2,3,[Golden],[Mare])
        INSERT INTO crsHorses VALUES (3,0,[Silverado],[Horse])
        INSERT INTO crsHorses VALUES (4,2,[Golden 12],[Mare])
        INSERT INTO crsHorses VALUES (5,1,[Golden 323],[Mare])
        INDEX ON BINTOC(Parent)+BINTOC(Idn) TAG crsHorses

        LOCAL lcNodeKey, lcNodeText
        thisform.AddObject('tree1', 'olecontrol', 'COMCtl.treectrl')
        WITH thisform.tree1
            .visible = .t.
            .height = thisform.height - 30
            .width = 300 &&thisform.width - 165
            .left = 16
            .top = 2
        ENDWITH
    ENDPROC


    PROCEDURE command1.Click
        LOCAL lcNodeKey, lcNodeText
        *** Get the record where the paretn_id is zero
        *** This is the root node
        *IF SEEK( 0, [FamilyData], [Parent_fk] )
        *IF SEEK( thisform.combo1.Value , "cv", "idn")
        IF SEEK( BINTOC(0)+BINTOC(3), "crsHorses", "crsHorses")
          *** This is the root level node so add it
          lcNodeKey =  [P] + ALLTRIM(transform(Idn))
          lcNodeText = ALLTRIM(crsHorses.Name)
          Thisform.Tree1.Nodes.Add( , , lcNodeKey, lcNodeText ) 
        ENDIF
        thisform.AddChilds(3)
        thisform.Tree1.Nodes(lcNodeKey).Expanded = .t.
    ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform