...
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); ClipToColRow(StringGrid1, 1, 1, Str);
end;
...