Search code examples
delphicopyclipboardpaste

How to select a specific row from ClipBoard


I have copy text from multiple TEdit using sLineBreak, and I would like to paste the clipboard row by row in other TEdit

Thank you


Solution

  • You can use a TStringList to convert Clipboard.AsText to a list of separate lines. Then get individual lines from the string list using the strings index. For example:

    procedure TForm21.Button1Click(Sender: TObject);
    var
      sl: TStringList;
    begin
      sl := TStringList.Create;
      try
        sl.Text := clipboard.AsText;
        Edit1.Text := sl[2];
      finally
        sl.Free;
      end;
    end;