Delphi下Treeview控件基于节点编号的访问(2)
2008-04-09 04:26:15来源:互联网 阅读 ()
else //在第二层或第二层以上节点中搜索
begin
GoStep:=StrToInt(Copy(inNumCode,i,j-i 1));
ReturnNode:=SearchInNode.Item[GoStep-1];
end;
SearchInNode:=ReturnNode;
i:=j 2
end;
Result:=SearchInNode;
end;
function TCtrlTree.LocateNodeInLevel(parNode: TTReeNode;LevelCode: integer): TTReeNode;
{功能:根据父节点以及在兄弟节点中的编号找到对应的节点
如果要创建兄弟及自己,则新创建的节点的Text为Temp
入口参数:parNode: TTReeNode为父节点
LevelCode: integer为编号
返回:在parNode中编号为LevelCode的孩子节点
}
var
i:integer;
j:integer;
tmp:TTreeNode;
tmps:TTreeNode;
begin
//父节点为空,是第一层节点
tmp:=nil;
if parNode=nil then
begin
i:=1;
tmps:=Items.GetFirstNode;
while (tmps<>nil) and (i<=LevelCode) do
begin
tmp:=tmps;
tmps:=tmps.getNextSibling;
i:=i 1;
end;
i:=i-1;
for j:=1 to LevelCode-i do
tmp:=Items.AddChild(nil,''''Temp'''');
Result:=tmp;
end
else //父节点不为空,正常处理
begin
if parNode.Count<LevelCode then
for i:= 1 to LevelCode-parNode.Count do
Items.AddChild(parNode,''''Temp'''');
Result:=parNode.Item[LevelCode-1];
end;
end;
function TCtrlTree.GetPosAtBound(inString: String;inStart:Integer): Integer;
{功能:根据起始位置找到下一个''''.''''的前一个位置
入口参数:inString: String节点编号
inStart: Integer当前处理层次的起始位置
返回:当前处理层次的结束位置
}
var
tmp:Char;
pos:integer;
begin
pos:=inStart 1;
while pos <= Integer(StrLen(PChar(inString))) do
begin
tmp:=inString[pos];
if tmp=''''.'''' then
Break
else
pos:=pos 1;
end;
Result:=pos-1;
end;
function TCtrlTree.GetTheLastPointPos(inString: String): Integer;
{功能:找到编号中最后的''''.''''的位置
入口参数:inString: String为节点编号
返回:节点编号中最后的''''.''''的位置
}
var
tmp:Char;
pos:integer;
begin
pos:=Integer(StrLen(PChar(inString)));
while pos>=1 do
begin
tmp:=inString[pos];
if tmp=''''.'''' then
Break
else
pos:=pos-1;
end;
Result:=pos;
end;
function TCtrlTree.InsertAsFinalChild(inString: String; inNode: TTreeNode):TTReeNode;
{功能:为当前节点插入一个孩子节点,位置为最后
入口参数:inString: String为节点编号为待插入节点的字符串
inNode: TTreeNode,当前节点
}
begin
Result:=Items.AddChild(inNode,inString);
end;
function TCtrlTree.InsertAsPreviousSibling(inString: String;
inNode: TTreeNode):TTReeNode;
{功能:为当前节点插入一个前导的兄弟节点
入口参数:inString: String为节点编号为待插入节点的字符串
inNode: TTreeNode,当前节点
}
begin
Result:=Items.AddChildFirst(inNode,inString);
end;
end.
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:RDL 入门起步
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash
