1 /// <summary>
 2 /// 设置光标位置
 3 /// </summary>
 4 /// <param name="passwordBox"></param>
 5 /// <param name="start">光标开始位置</param>
 6 /// <param name="length">选中长度</param>
 7 private void SetSelection(PasswordBox passwordBox, int start, int length)
 8 { 
 9     passwordBox.GetType()
10                .GetMethod("Select", BindingFlags.Instance | BindingFlags.NonPublic)
11                .Invoke(passwordBox, new object[] { start, length }); 
12 } 

以上方法中 start传光标位置,length传0,即可控制

相关文章:

  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2021-11-17
  • 2021-09-16
  • 2022-12-23
  • 2021-05-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2021-07-31
  • 2021-07-31
  • 2021-12-15
相关资源
相似解决方案