Print Page | Close Window

Changing the ErrorProvider Behavior for Loose Controls

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=46
Printed Date: 12-Jun-2026 at 11:24am


Topic: Changing the ErrorProvider Behavior for Loose Controls
Posted By: Customer
Subject: Changing the ErrorProvider Behavior for Loose Controls
Date Posted: 06-Jun-2007 at 1:06pm

Question:

How can I change DevForce’s UI behavior in response to a data validation failure?  I don’t want the flashing exclamation point!




Replies:
Posted By: IdeaBlade
Date Posted: 06-Jun-2007 at 1:08pm

Answer:

The following snippet shows you how you can gain access to the ErrorProvider of a control to change its properties, or replace it entirely:

 

      // For some Control pControl, retrieve its data bindings

      foreach(Binding aBinding in pControl.DataBindings) {

        // Cast the binding to an IdeaBladeBinding

        IdeaBladeBinding binding = aBinding as IdeaBladeBinding;

       

        if (binding != null && binding.PropertyName == "SomeBindingPropertyName") {

          // e.g. Change blinking to never blink.

          ErrorProvider errorProvider = binding.ErrorProvider;

          errorProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink;

 

          // or

 

          // e.g. Replace ErrorProvider entirely

          binding.ErrorProvider = ModifiedErrorProvider;       

        }

      }

If, however, you are interested in modifying the default exception-handling behavior of a DevForce data binding, please consult the section in the Developer’s Guide titled “Modifying the Default Error Handling Behavior of the Binding.” This section describes a couple of ways to do this as well as an example of how you can replace the ControlBindingDescriptor’s Error event with your own handler.




Print Page | Close Window