.NET Framework Class Library
Clipboard..::.SetText Method (String)

Stores UnicodeText data on the Clipboard.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)
Syntax

Visual Basic (Declaration)
Public Shared Sub SetText ( _
    text As String _
)
Visual Basic (Usage)
Dim text As String

Clipboard.SetText(text)
C#
public static void SetText(
    string text
)
Visual C++
public:
static void SetText(
    String^ text
)
JScript
public static function SetText(
    text : String
)
XAML
You cannot use methods in XAML.

Parameters

text
Type: System..::.String
A string that contains the UnicodeText data to store on the Clipboard.
Exceptions

ExceptionCondition
ArgumentNullException

textData is nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

This data format denotes 16-bit character encoded Unicode, also referred to as UTF-16, and UCS-2.

This method adds data with auto-conversion disabled.

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Tags :


Community Content

Tom A Cox
Exceptions
This method may throw a COMException if it cannot access the clipboard. For example:

System.Runtime.InteropServices.COMException (0x800401D0): OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Windows.Clipboard.CriticalSetDataObject(Object data, Boolean copy)
at System.Windows.Clipboard.SetDataInternal(String format, Object data)
Tags :

Page view tracker