Ver Mensaje Individual
  #2  
Antiguo 21-03-2013
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola Cristhor1982.

Basándome en el ejemplo de tu mensaje:
Cita:
123,456,789
101,110,121,015
125
235-785
2512 8545
Podrías hacer:
Código Delphi [-]
...
uses Clipbrd;

procedure ClipToColRow(SG: TStringGrid; const aCol, aRow:Integer; const Str: string);
var
  SL: TStrings;
  i : Integer;
begin
  SL:= TStringList.Create;
  try
    SL.Delimiter     :=',';
    SL.DelimitedText := Str;
    SG.RowCount:= SL.Count + 1;
    for i := 0 to SL.Count-1 do
       SG.Cells[SG.FixedCols, SG.FixedRows+i] := SL[i];
  finally
    SL.Free
  end
end;

procedure TForm1.btnToSGridClick(Sender: TObject);
var
  Str: string;
  SL: TStrings;
  i : Integer;
begin
  if Clipboard.HasFormat(CF_TEXT) then
  begin
    SL:= TStringList.Create;
    try
      SL.Text:= Clipboard.AsText;
      for i:= 0 to SL.Count-1 do
        if i < SL.Count-1 then SL[i]:= SL[i] + ',';
      Str := SL.Text;
      Str := StringReplace(Str, '-', ',', [rfReplaceAll]);
      Str := StringReplace(Str, ' ', ',', [rfReplaceAll]);
      Str := StringReplace(Str, #10,  '', [rfReplaceAll]);
      Str := StringReplace(Str, #13,  '', [rfReplaceAll]);
      Clipboard.AsText:= Str;
    finally
      SL.Free
    end
  end;
  Str := InputBox('Dato', ':', Str); // esto podría ser innecesario...
  ClipToColRow(StringGrid1, 1, 1, Str);
end;
...
Podrías enviar directamente la variable Str como parámetro de la función ClipToColRow sin pasar por el InputBox.

Saludos.
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 21-03-2013 a las 21:39:09. Razón: comentario
Responder Con Cita