本文整理匯總了C#中System.Windows.Clipboard.SetDataObject方法的典型用法代碼示例。如果您正苦於以下問題:C# Clipboard.SetDataObject方法的具體用法?C# Clipboard.SetDataObject怎麽用?C# Clipboard.SetDataObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Clipboard
的用法示例。
在下文中一共展示了Clipboard.SetDataObject方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DataObject
// For this example, the data to be placed on the clipboard is a simple
// string.
string textData = "I want to put this string on the clipboard.";
// The example will enable auto-conversion of data for this data object.
bool autoConvert = true;
// Create a new data object, specifying the data format, data to encapsulate, and enabling
// auto-conversion services.
DataObject data = new DataObject(DataFormats.UnicodeText, (Object)textData, autoConvert);
// If the data to be copied is supposed to be persisted after the application ends,
// then set the second parameter of SetDataObject to true.
if(persistentData)
{
// Place the persisted data on the clipboard.
Clipboard.SetDataObject(data, true);
}
else
{
// Place the non-persisted data on the clipboard.
Clipboard.SetDataObject(data, false);
}
// If you keep a copy of the source data object, you can use the IsCurrent method to see if
// the data object is still on the clipboard.
bool isOriginalDataObject = Clipboard.IsCurrent(data);