PasswordBox.Paste 方法

定义

用剪贴板中的内容替换 PasswordBox 中的当前选定内容。

public:
 void Paste();
public void Paste ();
member this.Paste : unit -> unit
Public Sub Paste ()

示例

以下示例演示如何使用Paste该方法将内容粘贴到其中PasswordBox

  // A TextBox will serve as a contrived means of putting our test 
  // password on the Clipboard.
  TextBox txtBox = new TextBox();
  PasswordBox pwdBox = new PasswordBox();

  // Put some content in the TextBox, and copy it to the Clipboard.
  txtBox.Text = "Open Sesame!";
  txtBox.SelectAll();
  txtBox.Copy();

  // Paste the contents of the Clipboard into the PasswordBox.  After this
  // call, the value of pwdBox.Password == "Open Sesame!".
  pwdBox.Paste();
' A TextBox will serve as a contrived means of putting our test 
' password on the Clipboard.
Dim txtBox As New TextBox()
Dim pwdBox As New PasswordBox()

' Put some content in the TextBox, and copy it to the Clipboard.
txtBox.Text = "Open Sesame!"
txtBox.SelectAll()
txtBox.Copy()

' Paste the contents of the Clipboard into the PasswordBox.  After this
' call, the value of pwdBox.Password == "Open Sesame!".
pwdBox.Paste()

注解

此方法不会清除粘贴前的内容;它将将当前选定内容替换为粘贴的内容 PasswordBox ,或将粘贴的内容插入到当前光标位置。

适用于