errorprovider and BindingSource, but no errors until user clicks Okerrorprovider and BindingSource, but no errors until user clicks Ok
Old forum URL: forums.lhotka.net/forums/t/3202.aspx
mtagliaf posted on Monday, July 16, 2007
I have a dialog bound to a CSLA object - all of the fields are empty to start with. Many of the fields are required.
I'm using an ErrorProvider bound to a BindingSource, but I don't want the little red ! symbols to show up until the user clicks "Ok" for the first time. As it is set up now, validation rules are checked and all the required fields show up with the ! symbols right when the dialog is opened.
I thought maybe I could create the errorprovider at runtime when the user clicks OK, but that doesn't seem to be working either.
matt tag
stanc replied on Monday, July 16, 2007
I'm still kinda new to CSLA, but based on what I know your problem lies in your Business Object. In the DataPortal_Create you probably have a ValidationRules.CheckRules() call. Hope this leads you in the right direction. Maybe someone can correct me if I am wrong.
Stan
RockfordLhotka replied on Monday, July 16, 2007
One answer might be to add an IsInitialized flag to your object. It would start as False, and you'd set it to True once you want rules to start working.
Then you'd add a rule at priority zero to each property. This rule would always return True, but would set e.StopProcessing=True if IsInitialized is False.
All your other rules would then be added at priority 1.
And you'd set the process through threshold to 1 (it defaults to 0).
The end result is that no real rules would run until IsInitialized was set to True.
Copyright (c) Marimer LLC