zoukankan      html  css  js  c++  java
  • 正序删除虚拟树所选择的行 技巧

    procedure TForm1.miDelClick(Sender: TObject);
    var
      Node: PVirtualNode;
      item: TUpdataFile;
      index, ioffset: integer;
    begin
      ioffset := 0;
      Node := self.vstFiles.FocusedNode;
      if (not Assigned(Node)) then
        Exit;
      if (self.vstFiles.SelectedCount < 1) then
        Exit;
      try
        self.vstFiles.BeginUpdate;
        Node := vstFiles.GetFirstSelected(); // 特点从第一个选择开始删除的
        while Assigned(Node) do
        begin
          item := self.fPack.List[Node.index - ioffset]; // 技巧 2017-1-19 11:27
          self.fPack.DelFile(item);
          Node := vstFiles.GetNextSelected(Node);
          inc(ioffset); //每删除一个,就记录以及删除了多少个
        end;
    
      finally
        self.vstFiles.RootNodeCount := self.fPack.List.Count;
        self.vstFiles.EndUpdate;
        self.vstFiles.Invalidate;
      end;
    
    end;

    注:此情形选择的 行的 index从小到大,如果不用此方法,会造成越界异常。

  • 相关阅读:
    bzoj3280
    bzoj3876
    洛谷 p1625
    bzoj1407
    bzoj1227
    bzoj1477 && exgcd学习笔记
    bzoj1345
    c#程序的config文件问题
    思维角度的重要性
    python异步初步窥探
  • 原文地址:https://www.cnblogs.com/rogge7/p/6374832.html
Copyright © 2011-2022 走看看