none
ErrorProvider is not showing in the first time RRS feed

  • Question

  • Hi all!

     

    I am using ErrorProvider control and it is working correctly when I change the combobox's value.

     

    But, for example, when I start a new order I use the customer that is already selected on the combobox. In this case, if the customer is not active, I call errorProvider.SetError(customerComboBox, "Error message..."), and it is not showing the error message. Just shows if I change to another customer and select that customer again.

     

    Does anyone know what is going wrong?

     

    Thank you,
    Vanessa

    Friday, April 4, 2008 8:55 PM

Answers

  • Hi,

     

    I don't know where you write your validation logic. Normally the Validating or Validated event is used. In this case the validation only occurs whenn the control is loosing the focus. In other words if the control never has the focus there will be no validation.

    But you can trigger validation from code:

    assume you are in an event handler of your form ('this' refers to the instance of your form)

    1. this.Validate();

    This causes validation on the control which lost the focus

    2. this.ValidateChildren()   

    This will trigger validation on all child controls in your form.

     

    By the way, validation only happens if both controls (the one which looses the focus and the one which gets the focus) have the property CausesValidation set to true.

     

    regards

    Philipp

    Friday, April 4, 2008 10:08 PM