Skip to content

Instantly share code, notes, and snippets.

@hpcorona
Created January 13, 2012 19:46
Show Gist options
  • Save hpcorona/1608339 to your computer and use it in GitHub Desktop.
Save hpcorona/1608339 to your computer and use it in GitHub Desktop.
Code to Copy a Tree Node from a TableTreeView on WinDev
PROCEDURE CopyTreeNode(LOCAL TableTree, nIdx is int)
sRow is string = ""
// If no item is selected, then return an empty string
IF {TableTree, indItem} < 1 THEN RESULT ""
// Count the columns, we'll need them
CCount is int = TableCount(TableTree,toColumn)
// Get the Parent, so we know when to stop seeking for childs
ParentIdx is int = TableGiveParent(TableTree, nIdx)
FOR i = nIdx _TO_ TableCount(TableTree)
IF i > nIdx _AND_ TableGiveParent(TableTree, i) <= ParentIdx THEN BREAK
// sThis will store the current row
// The first field will always contain the parent index
sThis is string = TableGiveParent(TableTree, i) - nBase
IF i = nIdx THEN
sThis = "0"
END
FOR j = 1 _TO_ CCount
sThis += Charact(1) + {TableTree, indControl}[i][j]
END
IF sRow <> "" THEN
sRow += Charact(2)
END
sRow += sThis
END
RESULT sRow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment