ClipboardProxy.SetText 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在剪貼簿上寫文字。
多載
| 名稱 | Description |
|---|---|
| SetText(String) |
在剪貼簿上寫文字。 |
| SetText(String, TextDataFormat) |
在剪貼簿上寫文字。 |
SetText(String)
在剪貼簿上寫文字。
public:
void SetText(System::String ^ text);
public void SetText(string text);
member this.SetText : string -> unit
Public Sub SetText (text As String)
參數
- text
- String
String。 文字待寫。 Required.
例外狀況
text 是空字串。
text 是 Nothing。
範例
這個範例是將字串 This is a test string. 寫入剪貼簿。
My.Computer.Clipboard.SetText("This is a test string.")
備註
可能的格式有 CommaSeparatedValue、 Html、 RtfUnicodeText和 。
先前的剪貼簿格式未被保存。
Important
由於剪貼簿可能被其他使用者存取,請勿用它來儲存敏感資訊,例如密碼或機密資料。
依專案類型提供可用性
| 專案類型 | Available |
|---|---|
| Windows 應用程式 | Yes |
| 類別庫 | Yes |
| 主控台應用程式 | Yes |
| Windows 控件庫 | Yes |
| Web 控制庫 | No |
| Windows 服務 | Yes |
| 網站 | No |
另請參閱
適用於
SetText(String, TextDataFormat)
在剪貼簿上寫文字。
public:
void SetText(System::String ^ text, System::Windows::Forms::TextDataFormat format);
public void SetText(string text, System.Windows.Forms.TextDataFormat format);
member this.SetText : string * System.Windows.Forms.TextDataFormat -> unit
Public Sub SetText (text As String, format As TextDataFormat)
參數
- text
- String
String。 文字待寫。 Required.
- format
- TextDataFormat
TextDataFormat。 撰寫文字時使用的格式。 預設值為 UnicodeText。 Required.
例外狀況
text 是空字串。
text 是 Nothing。
範例
這個範例是將字串 This is a test string. 寫入剪貼簿。
My.Computer.Clipboard.SetText("This is a test string.")
備註
可能的格式有 CommaSeparatedValue、 Html、 RtfUnicodeText和 。
先前的剪貼簿格式未被保存。
Important
由於剪貼簿可能被其他使用者存取,請勿用它來儲存敏感資訊,例如密碼或機密資料。
依專案類型提供可用性
| 專案類型 | Available |
|---|---|
| Windows 應用程式 | Yes |
| 類別庫 | Yes |
| 主控台應用程式 | Yes |
| Windows 控件庫 | Yes |
| Web 控制庫 | No |
| Windows 服務 | Yes |
| 網站 | No |