2009-06-13 100 views

答えて

10

あなたはPasswordBoxに選択を設定するには、このような何かを試すことができます。

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

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

いいえ、PasswordBoxのAPIはこれを行う方法を公開していません。

+0

おかげでケント:その後

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

を、カーソル位置を設定するには、このようにそれを呼び出します。私はテキストボックスコントロールを使用してこれを達成する方法があります。 – deepak

+0

それはあなたのためにテキストボックスでそれを行う必要があります: 'textBox.Select(textBox.Text.Length、0)' –

関連する問題