I built a CRUD interface using a ListBox to try and simulate a datagrid—I didn’t really like the standard Datagrid control. However, I’m struggling to validate the cells in each row. I’m not sure if I’m doing it wrong. Delete and Add work fine, but I’m having trouble with validation for new cells and updates. Could anyone share an example that works well? I’d really appreciate it.
What do you mean with validation?
If you are talking about testing that the record has internal consistency? I would wait until the user chooses to save it (or navigates away, if that is a save point).
At that point check the fields together prior to saving. If you try and check it field by field you will find all sorts of issues such as, fields that are yet to be entered which will complicate the validation.
A major fix is to not allow a user to enter invalid data in the first place. For example if the question is “Male” or “Female”, or any similar discrete value choice, always use a pop up menu with only those choices. Don’t ever allow them to type into the field. You don’t have to display data that way, just enter it.
Often an interface will provide a “form” for data editing. It can be better for the user to see a page with just the single record than the data strung out across a thin line. If you are entering new data, you can provide a “Save and enter another” type button. This saves having to open and close the dialog over and over for multiple records.