如何删除memo1中的空白行?

解决方案 »

  1.   

    while Pos(#13#10#13#10, Memo1.Text) > 0 do
      Memo1.Text := StringReplace(Memo1.Text, #13#10#13#10, #13#10, [rfReplaceAll]);
    //or
    var
      I: Integer;
    begin
      with Memo1.Lines do
      begin
        BeginUpdate;
        try
          for I := Count - 1 downto 0 do
            if Strings[I] = '' then Delete(I);
        finally
          EndUpdate;
        end;
      end;
    end;
      

  2.   

    for i:=memo.lines.count-1 do 0 do
    begin
      if (Trim(Memo.lines[i])=EmptyStr then
        Memo.Delete[i];
      Inc(i);
    end;我这里没有delphi,但愿没有写错吧...
      

  3.   

    for i:=memo.lines.count-1 downto 0 do
    begin
      if (Trim(Memo.lines[i])=EmptyStr then
        Memo.Delete[i];
      Inc(i);
      Application.ProcessMessage;
    end;