Class
ClipboardEx

A class providing additional methods for working with the clipboard.

Definition

Namespace:Telerik.Windows.Documents.Base

Assembly:Telerik.Windows.Controls.RichTextBox.dll

Syntax:

cs-api-definition
public static class ClipboardEx

Inheritance: objectClipboardEx

Properties

ClipboardHandlers

Collection of ClipboardHandlers that will be used when getting rich-text content from the clipboard.

Declaration

cs-api-definition
public static List<ClipboardHandler> ClipboardHandlers { get; }

Property Value

List<ClipboardHandler>

The clipboard handlers.

Methods

ContainsDocument()

Determines whether the clipboard contains supported rich-text data.

Declaration

cs-api-definition
public static bool ContainsDocument()

Returns

bool

true if the clipboard contains document; otherwise, false.

ContainsText(KeyEventArgs)

Determines whether the clipboard contains plain text.

Declaration

cs-api-definition
public static bool ContainsText(KeyEventArgs pasteKeyEventArgs)

Parameters

pasteKeyEventArgs

KeyEventArgs

The KeyEventArgs instance containing the event data. Use null if such is not present./>

Returns

bool

true if the clipboard contains text; otherwise, false.

GetDocument()

Obtains a DocumentFragment from the clipboard using the registered ClipboardHandlers.

Declaration

cs-api-definition
public static DocumentFragment GetDocument()

Returns

DocumentFragment

a DocumentFragment instance representing the document created from the content inside the clipboard. If the operation is not successful, the method returns null.

GetDocument(out PasteSource?)

Obtains a DocumentFragment from the clipboard using the registered ClipboardHandlers.

Declaration

cs-api-definition
public static DocumentFragment GetDocument(out PasteSource? pasteSource)

Parameters

pasteSource

PasteSource?

The PasteSource that is resolved during clipboard processing.

Returns

DocumentFragment

a DocumentFragment instance representing the document created from the content inside the clipboard. If the operation is not successful, the method returns null.

GetDocumentFromClipboard(string, Func<string, string>)

Gets a DocumentFragment from clipboard using the specified data format.

Declaration

cs-api-definition
public static DocumentFragment GetDocumentFromClipboard(string dataFormat, Func<string, string> clipboardStringFilter = null)

Parameters

dataFormat

string

The data format. You can use the set of formats provided in the class.

clipboardStringFilter

Func<string, string>

A function to filter the string inside the clipboard. This function is used when the content needs to be formatted additionally before creating a document from it.

HTML content inserted by MS Word can be stripped using StripHtmlClipboardFormatHeaders(string).

Returns

DocumentFragment

A DocumentFragment instance representing the content. If the operation did not succeed, the method return null.

GetDocumentFromClipboard(string, out PasteSource?, Func<string, string>)

Gets a DocumentFragment from clipboard using the specified data format.

Declaration

cs-api-definition
public static DocumentFragment GetDocumentFromClipboard(string dataFormat, out PasteSource? pasteSource, Func<string, string> clipboardStringFilter = null)

Parameters

dataFormat

string

The data format. You can use the set of formats provided in the class.

pasteSource

PasteSource?

The PasteSource that is resolved during clipboard processing.

clipboardStringFilter

Func<string, string>

A function to filter the string inside the clipboard. This function is used when the content needs to be formatted additionally before creating a document from it.

HTML content inserted by MS Word can be stripped using StripHtmlClipboardFormatHeaders(string).

Returns

DocumentFragment

A DocumentFragment instance representing the content. If the operation did not succeed, the method return null.

GetText()

Gets the clipboard data of type .

Declaration

cs-api-definition
public static string GetText()

Returns

string

The string representing the content or Empty if there is no text in the clipboard.

SetDataObject(IDataObject)

Places a specified data object in the system Clipboard.

Declaration

cs-api-definition
public static void SetDataObject(IDataObject dataObject)

Parameters

dataObject

IDataObject

A data object (an object that implements IDataObject) to place on the system Clipboard.

SetDocument(DocumentFragment)

Sets a document represented by a DocumentFragment instance to the system clipboard.

Declaration

cs-api-definition
public static void SetDocument(DocumentFragment documentFragment)

Parameters

documentFragment

DocumentFragment

The document fragment.

SetDocument(DocumentFragment, IDataObject)

Sets a document represented by a DocumentFragment instance to the specified data object.

Declaration

cs-api-definition
public static void SetDocument(DocumentFragment documentFragment, IDataObject dataObject)

Parameters

documentFragment

DocumentFragment

The document fragment.

dataObject

IDataObject

The object the document fragment should be inserted into.

SetText(string)

Stores data, specified as a string, in the system clipboard.

Declaration

cs-api-definition
public static void SetText(string textData)

Parameters

textData

string

The text data.

SetText(string, DataObject)

Stores data, specified as a string, in the specified data object.

Declaration

cs-api-definition
public static void SetText(string textData, DataObject dataObject)

Parameters

textData

string

The string representing the text data.

dataObject

DataObject

The data object.

StripHtmlClipboardFormatHeaders(string)

Strips the clipboard format headers from the HTML content inserted in the clipboard by MS Word. Skips all lines in the beginning containing ':'.

Declaration

cs-api-definition
public static string StripHtmlClipboardFormatHeaders(string clipboardText)

Parameters

clipboardText

string

The clipboard text.

Returns

string

The stripped HTML string.