Skip to main content

BaseView.CopyToClipboard() Method

Copies the selected record(s) to the Clipboard as text.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

public virtual void CopyToClipboard()

Remarks

The CopyToClipboard method copies the selected records to the Clipboard as text. Only the contents of the visible columns are copied. For group rows, this method copies only the values of the grouping columns. Records hidden under the collapsed group rows aren’t included.

If the GridOptionsBehavior.CopyToClipboardWithColumnHeaders option is enabled, the CopyToClipboard method also copies the column captions to the Clipboard.

Records in the Clipboard are separated by the newline strings (“\r\n”). The TAB character (“\t”) is used to separate the values within a record.

The currently selected record(s) can be accessed via the ColumnView.GetSelectedRows method.

The CopyToClipboard method is automatically called when the CTRL+C shortcut is pressed while a View is focused.

If the GridOptionsSelection.MultiSelectMode property equals CellSelect, the CopyToClipboard method copies data only from selected cells.

Note

Copying a large amount of data to the Clipboard can cause an exception if there are limited memory resources. To limit the number or rows when copying to the Clipboard, use the BaseView.MaxRowCopyCount property. If this property is set to -1 (the default value), all the selected records are copied to the Clipboard. Otherwise, the BaseView.MaxRowCopyCount property limits the number of records to be copied.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the CopyToClipboard member must not be invoked for these Views. The CopyToClipboard member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CopyToClipboard() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also