Ver Mensaje Individual
  #3  
Antiguo 21-03-2013
Avatar de Cristhor1982
Cristhor1982 Cristhor1982 is offline
Miembro
NULL
 
Registrado: dic 2012
Posts: 60
Reputación: 12
Cristhor1982 Va por buen camino
Thumbs up

Wow!!, excelente justo en el clavo, ahora tengo k modificar un par de cosas y toy, Muchas Gracias!!!

Te Pasaste ...Necesito un profe como tu 100%

Saludos

Cita:
Empezado por ecfisa Ver Mensaje
Hola Cristhor1982.

Basándome en el ejemplo de tu mensaje:


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.
Responder Con Cita