Lst_projet. DataController.DataSet.Locate ('pm_id', vpm_id,[]); BL:= Lst_projet. DataController.DataSet.getBookmark; Lst_projet. DataController.DataSet.GotoBookmark (BL); Lst_projet. SetFocus; Lst_projet. focusednode.expanded:=true;
=======================
Http://blog.163.com/[email protected]/blog/static/40662642201284250445/
First, export the Excel TXT HTML:
Uses Cxtlexportlink;
Cxexporttltoexcel (DM. Savedialog.filename,cxdbtreelist1,true,true); into Excel
Cxexporttltotext (DM. Savedialog.filename,cxdbtreelist1,true,true); INTO txt
Cxexporttltohtml (DM. Savedialog.filename,cxdbtreelist1,true,true); into HTML
---------------------------------------------------------------------------------------------------------------
Second, cxdbtreelist1 total number of records: ShowMessage (IntToStr (cxtreelist1. Visiblecount));
Cxdbtreelist1 index of the current record: ShowMessage (IntToStr (CxTreeList1.FocusedNode.VisibleIndex));
Cxdbtreelist1 How many columns: ShowMessage (IntToStr (cxtreelist1. Visiblecolumncount));
Cxdbtreelist1 the current record level: ShowMessage (IntToStr (cxTreeList1.FocusedNode.Level));
Cxdbtreelist1 automatic expansion: Cxtreelist1.fullexpand; Auto Expand
Cxdbtreelist1 Automatic folding: Cxtreelist1. Fullcollapse;
Cxdbtreelist1 node content: ShowMessage (cxdbtreelist1.focusednode.parent.values[0]);
Third, add, delete the node:
To increase the sibling node:
Procedure Tfr_bommglin.cxbutton1click (Sender:tobject);
var Node:tcxtreelistnode;
Begin
Node:=cxdbtreelist1.focusednode.parent.addchild;
Node. values[0]:= ' AAAAA ';
Node. Values[1]:=node. level;
End
To add a subordinate node:
Procedure Tfr_bommglin.cxbutton2click (Sender:tobject);
var Node:tcxtreelistnode;
Begin
Node:=cxdbtreelist1.focusednode.addchild; Add child nodes in first record: CxdbTreeList1.FocusedNode.AddChildFirst;
Node. values[0]:= ' AAAAA ';
Node. Values[1]:=node. level+1;
Cxdbtreelist1.focusednode.expanded:=true; Expand child nodes
End
To delete a node:
Clientdataset1.getbookmark;
CxdbTreeList1.FocusedNode.Delete; Delete the current node record; Delete the child node of the current node: CxdbTreeList1.FocusedNode.DeleteChildren;
CxDBTreeList1.DataController.GotoBookmark;
Multi-node Select Delete:
Cxdbtreelist1.deleteselection
Data set Control:
CxDBTreeList1.DataController.dataset.GotoFirst,//gotolast gotonext gotoprev Gotobookmark
CxDBTreeList1.DataController.dataset.Append; Cancel UpdateData
CxDBTreeList1.DataController.dataset.edit;
According to the cxdbtreelist with the Clientdataset1 record positioning:
First: Bl:=cxdbtreelist1.datacontroller.dataset.getbookmark;
Next: CxDBTreeList1.DataController.DataSet.GotoBookmark (BL);
Cxdbtreelist1.setfocus;
Multi-node selection fetch record:
For i:=0 to Cxdbtreelist1.selectioncount-1 do
Begin
ShowMessage (Cxdbtreelist1.selections[i]. VALUES[1]);
End
-------------------------------------------------------------------------------------------
Third, add the node image:
Put ImageList on the form first to Cxdbtreelist, and in the Getnodeimageindex event of Cxdbtreelist, write the following:
ProcedureCxdbtreelist1getnodeimageindex (sender:tcxcustomtreelist; Anode:tcxtreelistnode; Aindextype:
Tcxtreelistimageindextype;VarAindex:timageindex);
Var
I:integer;
Begin
//To add a marker to a tree node.
ForI=0ToAnode.valuecountDo
Begin
IfAnode.level=0Then
Begin
Anode.imageindex:=0;
End
Else
IfAnode.level=1Then
Begin
Anode.imageindex:=2;
End
Else
IfAnode.level=2 then
begin
Anode.imageindex := 1 end end;
end
Cxdbtreelist find nodes by record