删除tstringlist相同节点间的所有节点

解决方案 »

  1.   

    var
      str: string;
      i,index: integer;
    begin
      for i := 0 to mmo1.Lines.Count - 1 do
      begin
        str := mmo1.Lines[i];
        if i > 0 then
        begin
          index := mmo2.Lines.IndexOf(str);
          if index > -1 then
          begin
            while mmo2.Lines.Count > index + 1 do
            begin
              mmo2.Lines.Delete(index + 1);
            end;
          end;
        end;
        mmo2.Lines.Add(str);
      end;
      

  2.   

    mmo1,mmo2是TMemo,mmo2中是你要的结果
      

  3.   

    tstringlist 有对重复节点的处理 你仔细查看下MyStrList.Duplicates := dupIgnore; //在录入时将会忽略掉已存在的不添加  还有其他属性 accept, error 什么来着