Ver Mensaje Individual
  #20  
Antiguo 13-07-2005
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.964
Reputación: 29
delphi.com.ar Va camino a la fama
Cita:
Empezado por Crandel
El problema es que con Add, lo agrega en una sóla linea a todo el texto.
Se me ocurren varias formas de hacer esto, una es abusando de la función ExtractStrings:
Código Delphi [-]
var
  S: TStringList;
begin
  S := TStringList.Create;
  try
    ExtractStrings([], [], '1'#13#10'2'#13#10'3'#13#10'4', S);
    ShowMessageFmt('Líneas: %d'#13#10, [S.Count]);
  finally
    S.Free;
  end;
Otra es armando una funcioncita para poder usar AddStrings
Código Delphi [-]
  procedure AddLines(AStrings: TStrings; const AText: string);
  var
    S: TStringList;
  begin
    S := TStringList.Create;
    try
      S.Text := AText;
      AStrings.AddStrings(S);
    finally
      S.Free;
    end;
  end;
begin
  { AStrings es el TStrings que le anexaremos las nuevas líneas }
  AddLines(AStrings, '1'#13#10'2'#13#10'3'#13#10'4');
  ShowMessageFmt('Líneas: %d'#13#10, [AStrings.Count]);
end;


Cita:
Empezado por Crandel
El memo lo reconoce perfectamente, pero no se porque el StringList no.
Seguramente utilizas la propiedad Lines que es un TString en lugar de Text

Saludos!
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita