Dennica
Можно и так. Только нужно проверку поставить на пустой ATreeList. И нужно все таки понять для чего Data.
И вообще я не пойму на кой тебе при такой теме TreeList ?
while not Eof do begin
with tlAvailable.Add do begin
Values[0] := FieldValues['id'];
Values[1] := FieldValues['name'];
end;
Next;
end;
Add, Add ... - где построение дерева, где родитель, где дочерние узлы? Используй грид и не морочь голову.
Дерево строится где-то таким образом
function GetNodeFromData(Data: Integer): TcxTreeListNode;
var
Node: TcxTreeListNode;
begin
Result := nil;
with TreeList do
begin
if Count = 0 then
Exit;
Node := Items[0];
while Assigned(Node) do
begin
if Integer(Node.Data) = Data then
begin
Result := Node;
Break;
end;
Node := Node.GetNext;
end;
end;
end;
procedure LoadTree;
var
Node: TcxTreeListNode;
begin
with MainDM, TreeList do
begin
Node := Add(nil,Pointer(0));
Node.Texts[0] := 'Содержание';
with TpFIBDataSet.Create(nil) do
try
Database := dbBase;
Transaction := trRd;
SQLs.SelectSQL.Add('SELECT * FROM Таблица ORDER BY ID');
Active := True;
while not Eof do
begin
Node := AddChild(GetNodeFromData (FieldByName('Родительский ID').AsInteger),
Pointer(FieldByName('ID') .AsInteger));
Node.Texts[0] := FieldByName('Текст Нода').AsString;
Next;
end;
Active := False;
GotoBOF;
FocusedNode.Expand(False);
finally
Free;
end;
end;
end;
var
Node: TcxTreeListNode;
begin
Result := nil;
with TreeList do
begin
if Count = 0 then
Exit;
Node := Items[0];
while Assigned(Node) do
begin
<script type="text/javascript">
</script>
begin
Result := Node;
Break;
end;
Node := Node.GetNext ;
end;
end;
end;
Можно и так. Только нужно проверку поставить на пустой ATreeList. И нужно все таки понять для чего Data.
И вообще я не пойму на кой тебе при такой теме TreeList ?
while not Eof do begin
with tlAvailable.Add do begin
Values[0] := FieldValues['id'];
Values[1] := FieldValues['name'];
end;
Next;
end;
Add, Add ... - где построение дерева, где родитель, где дочерние узлы? Используй грид и не морочь голову.
Дерево строится где-то таким образом
function GetNodeFromData(Data: Integer): TcxTreeListNode;
var
Node: TcxTreeListNode;
begin
Result := nil;
with TreeList do
begin
if Count = 0 then
Exit;
Node := Items[0];
while Assigned(Node) do
begin
if Integer(Node.Data) = Data then
begin
Result := Node;
Break;
end;
Node := Node.GetNext;
end;
end;
end;
procedure LoadTree;
var
Node: TcxTreeListNode;
begin
with MainDM, TreeList do
begin
Node := Add(nil,Pointer(0));
Node.Texts[0] := 'Содержание';
with TpFIBDataSet.Create(nil) do
try
Database := dbBase;
Transaction := trRd;
SQLs.SelectSQL.Add('SELECT * FROM Таблица ORDER BY ID');
Active := True;
while not Eof do
begin
Node := AddChild(GetNodeFromData
Pointer(FieldByName('ID')
Node.Texts[0] := FieldByName('Текст Нода').AsString;
Next;
end;
Active := False;
GotoBOF;
FocusedNode.Expand(False);
finally
Free;
end;
end;
end;
function GetNodeFromNodeText(Text: String): TcxTreeListNode;
var
Node: TcxTreeListNode;
begin
Result := nil;
with TreeList do
begin
if Count = 0 then
Exit;
Node := Items[0];
while Assigned(Node) do
begin
if Node.Texts[0] = Text then
begin
Result := Node;
Break;
end;
Node := Node.GetNext ;
end;
end;
end;