<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>Hi</div>
<div> </div>
<div>I'm having trouble with TTreeView - no doubt due to ignorance. Does anyone have simple example(s) of builing and using a treeview?</div>
<div> </div>
<div>Here's the sort of ignorance I confess to:</div>
<div> </div>
<div>I have tv: TTreeview on a form, and code that adds some nodes:</div>
<div> </div>
<div> newnode := tv.items.addchild(nil, 'A');<br/>
newnode := tv.items.addchild(nil, 'B');<br/>
newnode := tv.items.addchild(newnode, 'B1');<br/>
newnode := tv.items.addchild(newnode, 'B12');<br/>
newnode := tv.items.addchild(newnode, 'B123'); </div>
<div> </div>
<div>and that builds a tree OK, schematically like this</div>
<div> </div>
<div><span style="font-family:courier new,courier,monospace;"><span style="line-height: 1.6em;">...A</span></span></div>
<div><span style="font-family:courier new,courier,monospace;"><span style="line-height: 1.6em;">...B</span></span></div>
<div><span style="font-family:courier new,courier,monospace;"><span style="line-height: 1.6em;">......B1</span></span></div>
<div><span style="font-family:courier new,courier,monospace;"><span style="line-height: 1.6em;">.........B12</span></span></div>
<div><span style="font-family:courier new,courier,monospace;"><span style="line-height: 1.6em;">............B123 </span></span></div>
<div> </div>
<div>If the treeview option tvoAutoExpand is True, I get the whole tree and can click about the tree and select nodes. But if tvoAutoExpand is False, the tree is (correctly) drawn collapsed, and clicking to expand (eg node B), or on a node with no children (eg Node A) both result in a SigSegV in include/treeview.inc at line 1590 <span style="line-height: 1.6em;">which is the indicated line here:</span></div>
<div> </div>
<div style="margin-left: 40px;">function TTreeNode.GetLevel: Integer;<br/>
// root is on level 0<br/>
var<br/>
ANode: TTreeNode;<br/>
begin<br/>
Result := 0;<br/>
ANode := Parent; <<<<<<<<<<<line 1590<br/>
while Assigned(ANode) do<br/>
begin<br/>
Inc(Result);<br/>
ANode := ANode.Parent;<br/>
end;<br/>
end; </div>
<div> </div>
<div> </div>
<div>Obvioiusly I'm missing a lot but I cannot find any example to dispel the fog. Anyone got one?</div>
<div> </div>
<div class="signature">Joe<br/>
-------------------------<br/>
Joe.Shepherd@cyberservices.com<br/>
Perth, WA, Australia.</div></div></body></html>