如果不用那个,用treeview自己写
参考了曹晓钢的代码
)
function TDbM.DbShowTreeView(var ATreeView: TTreeView): boolean;
var
Node,ParNode:TTreeNode;
DtPoint:^STring;
begin
with ADOQueryTreeViewList do
begin
connection:=ADOConnwage;
if Active=true then Active:=false;
SQL.Clear;
SQL.Add('select 部门名称,部门编号,上级部门编号,上级部门名称 from 公司信息表');
try
open;
first;
while not eof do
begin
ParNode:=DbFindPrtBybh(ATreeView,fields.fieldbyname('上级部门编号').AsString);
new(DtPoint);
DtPoint^:=fields.fieldbyname('部门编号').AsString;
Node:=ATreeView.Items.AddChildObject(ParNode,fields.fieldbyname('部门名称').AsString,DtPoint);
Next;
end;
result:=true;
except
result:=false;
end;
end;
end;
function TDbM.DbFindPrtBybh(var ATvw: TTreeView; Da: string):TTreeNode;
var
I:integer;
begin
result:=nil;
for I:=0 to ATvw.Items.Count-1 do
if string(ATvw.Items
.Data^)=Da then
begin
result:=ATvw.Items;
exit;
end;
end;