TTMSFNCDataGrid.CopyToClipboard Method
Copies cells to the system clipboard as tab-delimited text.
API unit family: TMSFNCDataGrid
Declaring type: TTMSFNCDataGrid
Inherited from: TTMSFNCCustomDataGrid
Syntax
procedure CopyToClipboard(ASelectedCells: Boolean = True);
void __fastcall CopyToClipboard(bool ASelectedCells = true);
Remarks
Columns are separated by tabs and rows by line breaks; multi-line values are quoted. Each value passes through OnSaveCellData. Nothing is copied when there is no selection. OnBeforeCopyToClipboard and OnAfterCopyToClipboard fire only for the keyboard shortcut, not for this method.
Parameters
| Name | Description |
|---|---|
ASelectedCells |
When True (default), copies the current selection range; when False, copies every cell including fixed cells. |
Related API
Usage examples
Copy and paste tab-delimited cell ranges via the system clipboard
The grid round-trips with Excel out of the box: copy the selection, paste from the clipboard, and configure what gets copied.
procedure TForm1.FormCreate(Sender: TObject);
begin
Grid.Options.Clipboard.IncludeHeaders := True; // include the header row
Grid.Options.Clipboard.OnlySelected := True; // only copy the selection
end;
procedure TForm1.CopyButtonClick(Sender: TObject);
begin
Grid.CopyToClipboard;
end;
procedure TForm1.PasteButtonClick(Sender: TObject);
begin
Grid.PasteFromClipboard;
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Grid->Options->Clipboard->Enabled = true; // allow copy and paste
Grid->Options->Clipboard->AllowRowGrow = true; // let a paste add rows
}
void __fastcall TForm1::CopyButtonClick(TObject *Sender)
{
Grid->CopyToClipboard();
}
void __fastcall TForm1::PasteButtonClick(TObject *Sender)
{
Grid->PasteFromClipboard();
}