public bool UpdateErrorProviderTextForProperty(string errorMessage, string propertyName)
        {
            if (string.IsNullOrEmpty(propertyName))
            {
                throw new ArgumentNullException("propertyName");
            }
            if (string.IsNullOrEmpty(errorMessage))
            {
                throw new ArgumentNullException("errorMessage");
            }
            bool    result = false;
            Binding bindingGivenPropertyName = this.GetBindingGivenPropertyName(propertyName);

            if (bindingGivenPropertyName != null)
            {
                ExchangeErrorProvider exchangeErrorProvider = this.enabledBindingSources[(BindingSource)bindingGivenPropertyName.DataSource];
                StringBuilder         stringBuilder         = new StringBuilder(exchangeErrorProvider.GetError(bindingGivenPropertyName.Control));
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.AppendLine();
                }
                stringBuilder.Append(errorMessage);
                Control errorProviderAnchor = InputValidationProvider.GetErrorProviderAnchor(bindingGivenPropertyName.Control);
                exchangeErrorProvider.SetError(errorProviderAnchor, stringBuilder.ToString());
                result = true;
            }
            return(result);
        }
        private void BindingCompleted(object sender, BindingCompleteEventArgs e)
        {
            Control errorProviderAnchor = InputValidationProvider.GetErrorProviderAnchor(e.Binding.Control);

            if (e.BindingCompleteState != BindingCompleteState.Success)
            {
                if (e.BindingCompleteContext == BindingCompleteContext.DataSourceUpdate)
                {
                    StrongTypeException ex = e.Exception as StrongTypeException;
                    if ((ex == null || ex.IsTargetProperty) && e.Binding.Control.Enabled)
                    {
                        this.GetErrorProvider((BindingSource)e.Binding.DataSource).SetError(errorProviderAnchor, e.ErrorText);
                        this.AddErrorBindingForControl(e.Binding);
                    }
                    e.Binding.ControlUpdateMode = ControlUpdateMode.Never;
                }
            }
            else
            {
                e.Binding.ControlUpdateMode = ControlUpdateMode.OnPropertyChanged;
                if (this.RemoveSuccessfulBindingForControl(e.Binding))
                {
                    this.GetErrorProvider((BindingSource)e.Binding.DataSource).SetError(errorProviderAnchor, string.Empty);
                }
            }
            e.Cancel = false;
            this.SetModifiedBindingMembers(e);
        }
        private void RaiseDataBoundPropertyChanged(object sender, EventArgs e)
        {
            Control control = sender as Control;

            if (control != null)
            {
                foreach (ExchangeErrorProvider exchangeErrorProvider in this.enabledBindingSources.Values)
                {
                    Control errorProviderAnchor = InputValidationProvider.GetErrorProviderAnchor(control);
                    exchangeErrorProvider.SetError(errorProviderAnchor, "");
                }
            }
            EventHandler eventHandler = (EventHandler)base.Events[InputValidationProvider.EventDataBoundPropertyChanged];

            if (eventHandler != null)
            {
                eventHandler(this, e);
            }
        }
        private void Control_EnabledChanged(object sender, EventArgs e)
        {
            Control control = (Control)sender;

            if (!control.Enabled)
            {
                foreach (object obj in control.DataBindings)
                {
                    Binding       binding       = (Binding)obj;
                    BindingSource bindingSource = binding.DataSource as BindingSource;
                    if (bindingSource != null)
                    {
                        ExchangeErrorProvider errorProvider = this.GetErrorProvider(bindingSource);
                        if (errorProvider != null)
                        {
                            Control errorProviderAnchor = InputValidationProvider.GetErrorProviderAnchor(control);
                            errorProvider.SetError(errorProviderAnchor, string.Empty);
                        }
                    }
                }
            }
        }