>I have a form with a grid and several buttons. When I add validation to fields in the grid, a failed validation doesn't prevent a button outside the grid from getting focus and clicking. I can't believe I've never noticed this behavior before. Is there an easy way around this? Failing validation on a field in a grid should prevent the form's save button from being clicked, for example.
And how would you handle, for example, a button outside the form - a "Save" button on the main toolbar? In the framework I have been using, such a button invokes a form method, form.OnSave().
For validation, I suggest putting all the validation in the Form.OnSave() method, or however you call the method that handles it. This solves problems as the one you mentioned (and the one I mentioned). It also makes it easier - nay, feasible - to do validations that span more than one field.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)