コード例 #1
0
        /// <summary>
        /// Pops up the Mask design dialog for the user to set the control's mask.
        /// </summary>
        public void SetMask()
        {
            string mask = MaskPropertyEditor.EditMask(_discoverySvc, _uiSvc, _maskedTextBox, _helpService);

            if (mask == null)
            {
                return;
            }

            PropertyDescriptor maskProperty = TypeDescriptor.GetProperties(_maskedTextBox)["Mask"];

            maskProperty?.SetValue(_maskedTextBox, mask);
        }
コード例 #2
0
        public void SetMask()
        {
            string str = MaskPropertyEditor.EditMask(this.discoverySvc, this.uiSvc, this.maskedTextBox, this.helpService);

            if (str != null)
            {
                PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.maskedTextBox)["Mask"];
                if (descriptor != null)
                {
                    descriptor.SetValue(this.maskedTextBox, str);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Edits the Mask property of the MaskedTextBox control from the PropertyGrid.
        /// </summary>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            if (context == null || provider == null)
            {
                return(value);
            }

            ITypeDiscoveryService discoverySvc = (ITypeDiscoveryService)provider.GetService(typeof(ITypeDiscoveryService));  // fine if service is not found.
            IUIService            uiSvc        = (IUIService)provider.GetService(typeof(IUIService));
            IHelpService          helpService  = (IHelpService)provider.GetService(typeof(IHelpService));
            string mask = MaskPropertyEditor.EditMask(discoverySvc, uiSvc, context.Instance as MaskedTextBox, helpService);

            if (mask != null)
            {
                return(mask);
            }

            return(value);
        }