#204683 - 2012-04-10 03:43 PM
Kf.Classic: How do I determine if TreeNode has Child Nodes ?l
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Guys,
again having trouble with my current project. Can't tell when looping through a TreeViews Node Collection if the current Node has child nodes in the next level (my TreeView will have 3 levels of Nodes, all checkable)
here's what I tried (one of Shawns samples adapted a bit to simulate more than one level of Nodes, totally unstylish, what I can't find is in the comment in the only function of the script)
Break On
global $l1, $l2
$= setoption("NoVarsInStrings","ON")
$System = CreateObject("Kixtart.System")
$f = split(readprofilestring(@scriptdir + "\Form.ini", "Form", ""),chr(10))
$Form = $System.Form()
$Form.Size = 640,480
$Form.Center()
$Form.ToolGroupBox = $Form.GroupBox()
$Form.ToolGroupBox.Height = 30
$Form.ToolGroupBox.Dock = 1
$Form.StatusGroupBox = $Form.GroupBox()
$Form.StatusGroupBox.Height = 20
$Form.StatusGroupBox.Dock = 2
$Form.TreeView1 = $Form.Controls.Add("TreeView")
$Form.TreeView1.Width = $Form.ClientWidth / 4
$Form.TreeView1.Dock = 3
$Form.TreeView1.ShowLines = 1
$Form.TreeView1.ShowPlusMinus = 1
$Form.TreeView1.ShowRootLines = 1
$Form.TreeView1.CheckBoxes = 1
$Form.TreeView1.OnClick = "treeView_Click()"
$Form.TreeView1.OnAfterSelect = "treeView_Click()"
$Form.Splitter1 = $Form.Splitter()
$Form.Splitter1.Dock = 3
$Form.TextBox1 = $Form.TextBox()
$Form.TextBox1.Multiline = 1
$Form.TextBox1.Dock = 5
for each $e in $f
if $e
$l1 = $Form.TreeView1.Nodes.Add($e)
$l2 = $Form.TreeView1.Nodes(ascan($f,$e)).Nodes.Add($e+" - " + readprofilestring(@scriptdir + "\Form.ini", "Form", $e))
endif
next
$Form.Show
While $Form.Visible
$=Execute($System.Application.DoEvents)
Loop
Exit 1
function treeView_Click()
dim $checkedNodes
for $i = 0 to $Form.Treeview1.Nodes.Count - 1
if $Form.Treeview1.Nodes($i).checked
$checkedNodes = $checkedNodes + $Form.Treeview1.Nodes($i).FullPath + @crlf
endif
; here would go something like
; if $Form.Treeview1.Nodes($i).HasChild ..
next
if $checkedNodes
$Form.TextBox1.Text = $checkedNodes
endif
endfunction
attached is the file I used to get input for the TreeView..
As you will see only the first level of checked Nodes will get displayed right of the splitter
Attachments
Form.ini (513 downloads) Description:
Edited by Jochen (2012-04-10 03:43 PM)
_________________________
|
Top
|
|
|
|
#204702 - 2012-04-11 07:36 PM
Re: Kf.Classic: How do I determine if TreeNode has Child Nodes ?l
[Re: ShaneEP]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Maybe something like this?...
function treeView_Click()
dim $checkedNodes, $i, $is
for $i = 0 to $Form.Treeview1.Nodes.Count - 1
if $Form.Treeview1.Nodes($i).checked
$checkedNodes = $checkedNodes + $Form.Treeview1.Nodes($i).FullPath + @crlf
endif
for $is = 0 to $Form.Treeview1.Nodes($i).Nodes.Count - 1
if $Form.Treeview1.Nodes($i).checked
$Form.Treeview1.Nodes($i).Nodes($is).checked = 1
$checkedNodes = $checkedNodes + $Form.Treeview1.Nodes($i).Nodes($is).FullPath + @crlf
else
$Form.Treeview1.Nodes($i).Nodes($is).checked = 0
endif
next
next
if $checkedNodes
$Form.TextBox1.Text = $checkedNodes
endif
endfunction
|
Top
|
|
|
|
#204705 - 2012-04-12 01:35 AM
Re: Kf.Classic: How do I determine if TreeNode has Child Nodes ?l
[Re: Lonkero]
|
ShaneEP
MM club member
Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
|
Still seems a little out of whack. I added this line to the form code to get a 3rd level.
$l3 = $l2.Nodes.Add($e+" - " + readprofilestring(@scriptdir + "\Form.ini", "Form", $e))
|
Top
|
|
|
|
#204727 - 2012-04-13 06:47 AM
Re: Kf.Classic: How do I determine if TreeNode has Child Nodes ?l
[Re: Lonkero]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 466 anonymous users online.
|
|
|