문제

I am using an error provider on my windows form. On submit of the form, I need to check if there is some error present on the form. Can I get if there is a error present in the error provider.

도움이 되었습니까?

해결책

Write a Validate() method that returns false if it fails validation and execute it from SaveButton handler. You should perform re-validation of all controls of the form in this method. Continue Save only when Validate() returns true.

You could use ErrorProvider.GetError to get an error of a particular control on your form, but to get all errors on the entire form you would need to iterate over all controls that use that particular ErrorProvider instance on your form anyway.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top