CodePudding user response:
delphi7CodePudding user response:
Use is ADOtable, when the first open the program using a query, can show the node, I use the treeview1. Items. After the clear again query node shows don't come outCodePudding user response:
Treeview1. Items. The clear is to clear all the existing node;"First open the program using a query, you can show the node", this should not you open the query is automatically loaded and populate the node data, there will be other code to handle node data, so only after you remove the original node data query again, certainly will not have a node,
See you just open the program after the query code behind it,
CodePudding user response:
There is a simple way to, you all code search "treeview1" where you can find on the operation process,CodePudding user response:
Procedure TForm1. The show ();Var
Node1, 2, node3 node4: TTreeNode;
I, j, k, l: Integer;
Id1, id2, id3: string;
The begin
Company:=';
GroupBox4. Hide;
GroupBox5. Hide;
ADOTable1. Active:=True;
ADOTable1. Filter:='Cstate=' + '0';
ADOTable1. Filtered:=True;
ADOTable2. Active:=True;
ADOTable3. Active:=True;
ADOTable4. Active:=True;
Try
TreeView1. Selected:=nil;
While not ADOTable1. Eof do
While not ADOTable2. Eof do
While not ADOTable3. Eof do
While not ADOTable4. Eof do
For I:=0 to ADOTable1. Do RecordCount - 1
The begin
Node1:=Treeview1. Items. The Add (nil, ADOTable1 FieldByName (" CompanyName "). AsString) are identical.
Node1. StateIndex:=1;
Node1. SelectedIndex:=ADOTable1. FieldByName (' CompanyID). AsInteger;
Id1:=ADOTable1 FieldByName (' CompanyID). AsString;
ADOTable2. Filter:='ToCompanyID=' + # 39 + id1 + # 39 + 'and Mstate=' + '0'.
ADOTable2. Filtered:=True;
For j:=0 to ADOTable2. Do RecordCount - 1
The begin
2:=TreeView1. Items. AddChildObject (node1, ADOTable2 FieldByName (' MainDepartmentName). AsString, nil);
2. StateIndex:=2;
2. SelectedIndex:=ADOTable2. FieldByName (' MainDepartmentID). AsInteger;
Id2:=ADOTable2 FieldByName (' MainDepartmentID). AsString;
ADOTable3. Filter:='ToMainDepartmentID=' + # 39 + id2 + # 39 + 'and MState=' + '0'.
ADOTable3. Filtered:=True;
For: k=0 to ADOTable3. Do RecordCount - 1
The begin
Node3:=TreeView1. Items. AddChildObject (2, ADOTable3 FieldByName (' SecondDepartmentName). AsString, nil);
Node3. StateIndex:=3;
Node3. SelectedIndex:=ADOTable3. FieldByName (' SecondDepartmentID). AsInteger;
Id3:=ADOTable3 FieldByName (' SecondDepartmentID). AsString;
ADOTable4. Filter:='ToDepartmentID=' + # 39 + id3 + # 39 + 'and Wstate=' + '0'.
ADOTable4. Filtered:=True;
For: l=0 to ADOTable4. Do RecordCount - 1
The begin
Node4:=TreeView1. Items. AddChildObject (node3, ADOTable4 FieldByName (' WorkerName '). AsString, nil);
Node4. StateIndex:=4;
Node4. SelectedIndex:=ADOTable4. FieldByName (' WorkerID). AsInteger;
ADOTable4. Next;
end;
ADOTable3. Next;
end;
ADOTable2. Next;
end;
ADOTable1. Next;
end;
Except,
ShowMessage (' no information ');
end;
TreeView1. FullExpand;
end;
CodePudding user response: