ListChanged and ValidationRules

ListChanged and ValidationRules

Old forum URL: forums.lhotka.net/forums/t/4180.aspx


gtryf posted on Wednesday, January 16, 2008

Hi all,

I have created a business object (Floorplan) which owns a list of characteristcs (Characteristics, instance of FloorplanCharacteristicsList). I have placed a validation rule which requires that said list contains at least one member, according to the instructions given in another thread:

1) Created a ListChanged handler for the Characteristcs property on the Floorplan object;

2) Created the validation rule in the floorplan object;

3) In the ListChanged handler I added a call to PropertyHasChanged("Code").

 

Code is another property of Floorplan, which is represented on my form by a textbox, so that whenever that rule is broken it can be displayed by an ErrorProvider.

 

The problem is that whenever I remove a member of Characteristcs, my program crashes with an ArgumentOutOfRangeException in external code. I use a grid (C1TrueDBGrid) to display the characteristcs and it seems that the exception occurs whenever the grid tries to repaint itself after a characteristc is removed.

 

The problem is resolved if I remove the call to PropertyHasChanged() from the ListChanged handler - but then I get no validation.

 

Any suggestions?

George

Copyright (c) Marimer LLC