Welcome to Foxite.COM Community Weblog Sign in | Join | Help
<January 2009>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Post Categories

Navigation

Emotion

UDF

Syndication

Populate Treeview from a cursor (Normal Table)

SELECT * FROM Mytable into cursor Mycursor

WITH THISFORM.TReeview
    .Nodes.Clear
    cALIAS = "Mycursor"
    lnFieldsCount = FCOUNT(cALIAS)
    SELECT &cALIAS
    P
=0
    ON ERROR P=P+1
    LOCAL NodeX as MSComctlLib.Node
    SCAN
        FOR
I = 1 TO lnFieldsCount
            * GET KEY
            cKey = ""
            FOR J = 1 TO I
                cFN
= FIELD(J)
                cFNV = EVALUATE(cFN)
                cFNV = IIF(VARTYPE(cFNV)="N",ALLTRIM(STR(cFNV)),ALLTRIM(cFNV))
                cKey = cKey+ cFN + "=" + cFNV + " "
            NEXT J

            * GER RELATION
            IF I = 1 THEN
               
cRel = ""
            ELSE
               
cRel = ""
                FOR J = 1 TO I-1
                    cFN  = FIELD(j)
                    cFNV = EVALUATE(cFN)
                    cFNV = IIF (TYPE([cFNV]) = "N",ALLTRIM(STR(cFNV)),ALLTRIM(cFNV))
                    cRel = cRel + cFN + "=" + cFNV + " "
                NEXT J
            ENDIF

            * GET TEXT
            cTxt = EVALUATE(FIELD(I))
            cTxt = IIF (TYPE([cTxt]) = "N",ALLTRIM(STR(cTxt)),ALLTRIM(cTxt))
            IF !EMPTY(cTxt)
                IF I = 1
                    NodeX = .Nodes.Add(,,cKey,cTxt,,)
                ELSE
                    NodeX = .Nodes.Add(cRel,4,cKey,cTxt,,)
                ENDIF
                NodeX.Sorted= .T.
            ENDIF
        NEXT
I
    ENDSCAN
ENDWITH

ON ERROR

Published Friday, May 30, 2008 10:52 AM by samir_ibrahim

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

What do you think?

(required) 
required 
(required) 
Powered by Community Server, by Telligent Systems