Example #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService service = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (service != null)
            {
                PersistPassword    password = (value as PersistPassword).Clone() as PersistPassword; // 使用Clone对象,触发PropertyValueChanged消息
                ChangePasswordForm dialog   = new ChangePasswordForm(password);
                if (service.ShowDialog(dialog) == DialogResult.OK)
                {
                    password.Set(dialog.NewPassword);
                    return(password);
                }
            }
            return(value);
        }
 public ChangePasswordForm(PersistPassword oldPassword)
 {
     InitializeComponent();
     this.oldPassword = oldPassword;
 }