简体   繁体   中英

How to achieve single validation for multiple object property change

I am using PropertyGrid.SelectedObjects (Winform control) property to show properties of multiple objects. I have custom descriptor for each property of each object which does a basic validation and executes business logic.

I would like execute only once the business logic only when all the validations are done. How to we do it?

Edit

PropertyGrid control when a value is set automatically uses MergedPropertyDescriptor which calls my custom descriptor's SetValue function in a loop which results in multiple business logic call. Which I want to avoid this without the use of any static variable

Edit2 This question is also posted in Microsoft Forums

Easiest:

myForm.submit = function() {
  if (checkValidation()) {
    // business logic;
    if (OK) return true;
  }
  return false;
};

I, personally, would prefer to simply use the submit method as a wrapper (the inner if-statement [when true] would call another [business logic] function which returns true or false).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM