怎样不用递归列一个分三级的TreeView,急啊!!帮帮我!!我可以给300分的 怎样不用递归列一个分三级的TreeView,急啊!!帮帮我!!我可以给300分的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写死,呵呵递归的..function TfrmPactItem.LoadNode(pid: Integer; pNode: TTreeNode): Boolean;type TtmpData = record no: string; id: Integer; pid: Integer; title: string; content: string; attachfile: string; end;var SaveData: array of TtmpData; I: Integer; RdCount: Integer; ChildCount: Integer; CurrNode: TTreeNode;begin Result := False; with LoginInf.MySQLPlus do begin Close; SQL.Clear; SQL.Add('select id, pid, title, content, no, attachfile from pactitem ' + 'where pid = ' + IntToStr(pid) + ' and pactno = ''' + FCurrPactNo + #39); Open; RdCount := RecordCount; SetLength(SaveData, RdCount); for I := 0 to RdCount - 1 do begin SaveData[I].id := Fields[0].AsInteger; SaveData[I].pid := Fields[1].AsInteger; SaveData[I].title := Fields[2].AsString; SaveData[I].content := Fields[3].AsString; SaveData[I].no := Fields[4].AsString; SaveData[I].attachfile := Fields[5].AsString; Next; end; Close; end; for I := 0 to RdCount - 1 do begin LoginInf.PactItem[FIndex].id := IntToStr(SaveData[I].id); LoginInf.PactItem[FIndex].pid := IntToStr(SaveData[I].pid); LoginInf.PactItem[FIndex].title := SaveData[I].title; LoginInf.PactItem[FIndex].content := SaveData[I].content; LoginInf.PactItem[FIndex].no := SaveData[I].no; LoginInf.PactItem[FIndex].currindex := IntToStr(FIndex); LoginInf.PactItem[FIndex].haschange := False; LoginInf.PactItem[FIndex].attachfile := SaveData[I].attachfile; LoginInf.PactItem[FIndex].status := ''; CurrNode := tvMain.Items.AddChild(pNode, SaveData[I].Title); CurrNode.Data := PChar(LoginInf.PactItem[FIndex].Currindex); Inc(FIndex); SetLength(LoginInf.PactItem, FIndex + 1); with LoginInf.MySQLPlus do begin Close; SQL.Clear; SQL.Add('select count(no) from pactitem where pid = ' + IntToStr(SaveData[I].id) + ' and pactno = ''' + FCurrPactNo + #39); Open; ChildCount := Fields[0].AsInteger; Close; end; if CurrNode.Parent = nil then begin CurrNode.ImageIndex := 4; CurrNode.SelectedIndex := 5; end else if ChildCount > 0 then begin CurrNode.ImageIndex := 2; CurrNode.SelectedIndex := 3; end else begin CurrNode.ImageIndex := 0; CurrNode.SelectedIndex := 1; end; if ChildCount > 0 then begin LoadNode(SaveData[I].id, CurrNode); end; end; Result := True;end; 如何在原先全屏的IE中更新内容 从3个已有的表,取数据组成一个新表的问题。谢谢了。解决了,马上结贴,给分。 存储过程怎么修改呀 关于三层结构疑问。 新年散分送礼:程序员适用函数及Delphi程序员参考大全下载 //怎么才可以把加上参数的整个SQL语句显示出来看看 delphi中如何把word中的数据导入到数据库中 sql server创建表格之前如何判断数据库中是否有同名的表格名,有的话则重新设定表格名 真的没有高手么,真的没人会么? 进化乎!!退化乎!!! 树形结构怎么用呀,我看了很多,但是没有明白原理,有那们大哥,可以相告,小弟不感激不尽!!! 小妹又要麻烦大家了?
type
TtmpData = record
no: string;
id: Integer;
pid: Integer;
title: string;
content: string;
attachfile: string;
end;
var
SaveData: array of TtmpData;
I: Integer;
RdCount: Integer;
ChildCount: Integer;
CurrNode: TTreeNode;
begin
Result := False;
with LoginInf.MySQLPlus do
begin
Close;
SQL.Clear;
SQL.Add('select id, pid, title, content, no, attachfile from pactitem '
+ 'where pid = ' + IntToStr(pid) + ' and pactno = ''' + FCurrPactNo
+ #39);
Open; RdCount := RecordCount;
SetLength(SaveData, RdCount); for I := 0 to RdCount - 1 do
begin
SaveData[I].id := Fields[0].AsInteger;
SaveData[I].pid := Fields[1].AsInteger;
SaveData[I].title := Fields[2].AsString;
SaveData[I].content := Fields[3].AsString;
SaveData[I].no := Fields[4].AsString;
SaveData[I].attachfile := Fields[5].AsString;
Next;
end;
Close;
end;
for I := 0 to RdCount - 1 do
begin
LoginInf.PactItem[FIndex].id := IntToStr(SaveData[I].id);
LoginInf.PactItem[FIndex].pid := IntToStr(SaveData[I].pid);
LoginInf.PactItem[FIndex].title := SaveData[I].title;
LoginInf.PactItem[FIndex].content := SaveData[I].content;
LoginInf.PactItem[FIndex].no := SaveData[I].no;
LoginInf.PactItem[FIndex].currindex := IntToStr(FIndex);
LoginInf.PactItem[FIndex].haschange := False;
LoginInf.PactItem[FIndex].attachfile := SaveData[I].attachfile;
LoginInf.PactItem[FIndex].status := ''; CurrNode := tvMain.Items.AddChild(pNode, SaveData[I].Title);
CurrNode.Data := PChar(LoginInf.PactItem[FIndex].Currindex);
Inc(FIndex);
SetLength(LoginInf.PactItem, FIndex + 1);
with LoginInf.MySQLPlus do
begin
Close;
SQL.Clear;
SQL.Add('select count(no) from pactitem where pid = ' +
IntToStr(SaveData[I].id)
+ ' and pactno = ''' + FCurrPactNo + #39);
Open;
ChildCount := Fields[0].AsInteger;
Close;
end; if CurrNode.Parent = nil then
begin
CurrNode.ImageIndex := 4;
CurrNode.SelectedIndex := 5;
end
else if ChildCount > 0 then
begin
CurrNode.ImageIndex := 2;
CurrNode.SelectedIndex := 3;
end
else
begin
CurrNode.ImageIndex := 0;
CurrNode.SelectedIndex := 1;
end; if ChildCount > 0 then
begin
LoadNode(SaveData[I].id, CurrNode);
end;
end;
Result := True;
end;