cxdbtreelist的按記錄查找節點


      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/bin0315@126/blog/static/40662642201284250445/

一、導出EXCEL   TXT   HTML:

uses cxTLExportLink;

 

cxExportTLToEXCEL(dm.SaveDialog.FileName,cxDBTreeList1,TRUE,TRUE);  //轉入EXCEL
cxExportTLToTEXT(dm.SaveDialog.FileName,cxDBTreeList1,TRUE,TRUE);     //轉入TXT
cxExportTLToHTML(dm.SaveDialog.FileName,cxDBTreeList1,TRUE,TRUE);     //轉入HTML

圖片

 

--------------------------------------------------------------------------------------------------------------- 

二、cxdbtreelist1共多少條記錄:     showmessage(inttostr(cxtreelist1.VisibleCount));

       cxdbtreelist1當前記錄的索引:  showmessage(inttostr(cxTreeList1.FocusedNode.VisibleIndex));

       cxdbtreelist1有多少列:             showmessage(inttostr(cxtreelist1.VisibleColumnCount));

       cxdbtreelist1當前記錄的層級:   showmessage(inttostr(cxTreeList1.FocusedNode.Level));

       cxdbtreelist1自動展開:             cxtreelist1.fullexpand; //自動展開

       cxdbtreelist1自動折疊 :               cxtreelist1.FullCollapse;

       cxdbtreelist1取上級節點內容:   ShowMessage(cxdbTreeList1.FocusedNode.Parent.Values[0]);

 

三、新增、刪除結點:

增加同級結點:

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;

 

增加下級節點:

procedure Tfr_bommglin.cxButton2Click(Sender: TObject);
var node:TcxTreeListNode;
begin
   node:=cxdbTreeList1.FocusedNode.AddChild;       //增加子節點在首記錄:cxdbTreeList1.FocusedNode.AddChildFirst;
   node.Values[0]:='aaaaa';
   node.Values[1]:=node.Level+1;
   cxdbTreeList1.FocusedNode.Expanded:=true;  //展開子節點
end;

 

 刪除節點:

ClientDataSet1.GetBookmark;
cxdbTreeList1.FocusedNode.Delete;     //刪除當前節點記錄;刪除當前節點的子節點:cxdbTreeList1.FocusedNode.DeleteChildren;
cxDBTreeList1.DataController.GotoBookmark;

多節點選擇刪除:

cxDBTreeList1.DeleteSelection

 

數據集控制:

cxDBTreeList1.DataController.dataset.GotoFirst; //GotoLast     gotonext    gotoprev   GotoBookmark

cxDBTreeList1.DataController.dataset.Append;         //cancel      updatedata

cxDBTreeList1.DataController.dataset.edit;

根據cxdbtreelist隨clientdataset1記錄定位:

首先:bl:=cxDBTreeList1.DataController.DataSet.GetBookmark;

接着:cxDBTreeList1.DataController.DataSet.GotoBookmark(bl);
          cxDBTreeList1.SetFocus;

 

   

 

多結點選擇取記錄:

  for i:=0 to cxDBTreeList1.SelectionCount-1 do
     begin
       ShowMessage(cxDBTreeList1.Selections[i].Values[1]);
    end;

 

-------------------------------------------------------------------------------------------

 三、增加節點圖片:

        先在窗體上放ImageList關聯到cxDBTreeList,在cxDBTreeList的GetNodeImageIndex事件中寫如下:

  procedure cxDBTreeList1GetNodeImageIndex(Sender:TcxCustomTreeList; ANode: TcxTreeListNode; AIndexType:
                       TcxTreeListImageIndexType; var AIndex: TImageIndex);
 var
    i :Integer;
  begin
    //給樹結點加上圖標
    for i := 0 to ANode.ValueCount do
      begin
     if ANode.Level = 0 then
         begin
           ANode.ImageIndex := 0;
         end
       else
       if ANode.Level = 1 then
         begin
           ANode.ImageIndex := 2;
         end
       else
       if ANode.Level = 2 then
         begin
           ANode.ImageIndex := 1;
         end;
     end;
 end;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM