Windows Forms: Bind Entity Properties to Textbox issue

Posts   
 
    
Posts: 93
Joined: 13-Feb-2008
# Posted on: 26-Feb-2008 23:20:51   

I'm working on setting up windows forms validation with:

Validator class Dependency Injection BindingSource ErrorProvider

Scenario: Single Entity with Textboxes bound to properties

Disclaimer: I'm a windows forms noob, most of my experience is with web technologies

Should I be calling


involvedEntity.SetEntityFieldError

or


throw new ORMEntityValidationException

inside the ValidateFieldValue override when there is an invalid value?

If I just set the entity error the user is still allowed to navigate to other textboxes, if I throw the exception they are not.

Another question. If I throw the exception while editing a textbox (so i'm locked into the text box) I thought that simply hitting the escape key was supposed to roll back the value and allow you to "leave" the control. I am not getting this result and was wondering if I'm doing something wrong, or expecting something that just doesn't happen.

Thanks in advance for any comments/suggestions.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Feb-2008 04:26:03   

becker-samm wrote:

I'm working on setting up windows forms validation with:

Validator class Dependency Injection BindingSource ErrorProvider

Scenario: Single Entity with Textboxes bound to properties

Disclaimer: I'm a windows forms noob, most of my experience is with web technologies

Should I be calling


involvedEntity.SetEntityFieldError

or


throw new ORMEntityValidationException

That depends upon your needs. I prefer to set the error info and present to the user (manage the error info at GUI level). You can use throws on methods like ValidateEntityBeforeSave, for example.

Is better to control that on your GUI. Your validator lets you set the info of the error when they occurred.

You can download the Validation example from the LLBLGen site to see some approaches to this.

Cheers.

David Elizondo | LLBLGen Support Team