每个节点需储存两个字符串,比如一个是显示的文件名,另一个是文件路径。但TTreeNode只有一个Text属性能储存字符串,不知还有没有其它属性可以,或者怎样给这个节点增加个属性如Hint(这个属性只要能储存字符串即可,不需做其它用途)。
2 回答

HUH函数
TA贡献1836条经验 获得超4个赞
赋值:
var ps:PString;
New(ps);
ps^='string';
Node.Data:=ps
读取:
var ps:PString;
ps:=Node.Data;
Result:=ps^;
多个值使用record,仍使用Node.Data

慕哥6287543
TA贡献1831条经验 获得超10个赞
//函算返回一个你在treeview1里单几得到的TTreeNode
function TForm1.getNode:TTreeNode;
begin
Result := TreeView1.Selected
end;
如果是不要自己去选择,要程序去判断,代码如下:
function TForm1.getNode:TTreeNode;
var
thisnode : TTreeNode;
begin
thisnode := TreeView1.Items.GetFirstNode;
while thisnode<>nil do
begin
if thisnode.text = '我的程序' then
begin
Result := thisnode;//得到你要的TTreeNode;
break;
end;
thisnode := thisnode.getnode;
end;
Result := nil;
end;
添加回答
举报
0/150
提交
取消