Created
January 13, 2012 20:02
-
-
Save hpcorona/1608418 to your computer and use it in GitHub Desktop.
Code to Paste a Tree Node in a TableTreeView in WinDev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROCEDURE PasteTreeNode(LOCAL TableTree, LOCAL nIdx is int, LOCAL CopiedNode is string, LOCAL AsChild is boolean = False) | |
nParentIdx is int = 0 | |
nRelPos is int = 0 | |
nRelIdx is int = nIdx | |
IF AsChild = False THEN | |
nParentIdx = TableGiveParent(TableTree, nIdx) | |
ELSE | |
nParentIdx = nIdx | |
nRelIdx = TableCount(TableTree) | |
END | |
FOR i = nParentIdx + 1 _TO_ TableCount(TableTree) | |
nChildParent is int = TableGiveParent(TableTree, i) | |
IF nChildParent < nParentIdx THEN BREAK | |
IF nChildParent = nParentIdx THEN | |
nRelPos++ | |
END | |
IF nRelIdx = i THEN BREAK | |
END | |
// Put the node below the target position | |
nRelIdx += 1 | |
sSingleRow is string | |
bFirst is boolean = True | |
nIdxBase is int | |
nCurrIdx is int | |
nCCount is int = TableCount(TableTree,toColumn) | |
FOR EACH STRING sSingleRow OF CopiedNode SEPARATED BY Charact(2) | |
IF bFirst THEN | |
nIdxBase = TableInsertChild(TableTree,nParentIdx,nRelPos) | |
nCurrIdx = nIdxBase | |
bFirst = False | |
ELSE | |
nParentOffset is int = ExtractString(sSingleRow,1,Charact(1)) | |
nCurrIdx = TableAddChild(TableTree,nIdxBase + nParent) | |
END | |
FOR i = 1 _TO_ nCCount | |
{TableTree, indItem}[nCurrIdx][i] = ExtractString(sSingleRow,i + 1,Charact(1)) | |
END | |
END | |
RESULT nIdxBase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment