Clipboard.GetData(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves data in a specified format from the Clipboard.
public:
static System::Object ^ GetData(System::String ^ format);
public static object GetData (string format);
static member GetData : string -> obj
Public Shared Function GetData (format As String) As Object
Parameters
- format
- String
A string that specifies the format of the data to retrieve. For a set of predefined data formats, see the DataFormats class.
Returns
An object that contains the data in the specified format, or null
if the data is unavailable in the specified format.
Exceptions
format
is null
.
Examples
The following example demonstrates the use of this method.
// After this line executes, IsHTMLDataOnClipboard will be true if
// HTML data is available natively on the clipboard; if not, it
// will be false.
bool IsHTMLDataOnClipboard = Clipboard.ContainsData(DataFormats.Html);
// If there is HTML data on the clipboard, retrieve it.
string htmlData;
if(IsHTMLDataOnClipboard)
{
htmlData = Clipboard.GetText(TextDataFormat.Html);
}
' After this line executes, IsHTMLDataOnClipboard will be true if
' HTML data is available natively on the clipboard; if not, it
' will be false.
Dim IsHTMLDataOnClipboard As Boolean = Clipboard.ContainsData(DataFormats.Html)
' If there is HTML data on the clipboard, retrieve it.
Dim htmlData As String
If IsHTMLDataOnClipboard Then
htmlData = Clipboard.GetText(TextDataFormat.Html)
End If
Applies to
See also
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
.NET