2009-06-13 9 views

Antwort

10

Sie können so etwas wie diese versuchen, die Auswahl der PasswordBox einzustellen:

private void SetSelection(PasswordBox passwordBox, int start, int length) { 
    passwordBox.GetType().GetMethod("Select", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(passwordBox, new object[] { start, length }); 
} 

Danach wird es so nennen sich die Cursor-Position zu setzen:

// set the cursor position to 2... 
SetSelection(passwordBox1, 2, 0); 

// focus the control to update the selection 
passwordBox1.Focus(); 
1

Nein, die API für PasswordBox bietet keine Möglichkeit, dies zu tun.

+0

Dank Kent. Gibt es eine Möglichkeit, dies mit dem Textfeld-Steuerelement zu erreichen. – deepak

+0

Das sollte es für Sie in einem Textfeld tun: 'textBox.Select (textBox.Text.Length, 0)' –