StrataFrame Forum

Ideas on how to use a combo for a three state boolean

http://forum.strataframe.net/Topic13007.aspx

By Greg McGuffey - 12/12/2007

I have several instances of boolean fields that require entry, but that really have no default. I.e. They need to be initially NULL (nothing), then the user must set a value before saving. The users would also like a combo, rather than a checkbox. Sigh...



Ideas on the best way to do this?



My attempts so far all are not working. What I'm using now a enum with three values: NotSet (0), No(1), Yes(2). The field in the BO is set as a Nullable(Of Boolean). The combo uses the enum. I've created a custom bindable field that translates the field from the Nullable(of Boolean) to the enum. I've bound the combo to this custom field. I'm not setting any values in SetDefaultValues event handlers, either at the BO level or the form level. The problems I'm having are:



- When a new record is navigated to, the combo says "No", not "Not Set". "No" is the first value in the combo, event though the combo is setup to NOT sort.

- When I go to save the new record, there is a broken rule that the field isn't set...I don't get this one at all. The combo is bound to a custom field that uses the value of the field. If it is "No", then should be set. I test if the field HasValue. If it does, I set it to Yes or No. If not, it doesn't have a value, it is set to NotSet.

- I have no idea how to handle required fields with this scenario. The custom field will always have a value set, but if the value is the "NotSet" enum, then, well, it isn't set.



Anyway, I'm pretty sure I'm missing something pretty obvious here and I'm hoping somebody can point me in the right direction!



Thanks!
By Keith Chisarik - 12/12/2007

Why not bind your BO to a hidden check box control (since that is what you wanted to use), have the combobox that the client wants manipulate its values, or am I missing something?
By Greg McGuffey - 12/26/2007

I ended up having to use a checkbox. I'll eventually just update the db for these fields to use an int and then setup an enum, which is easy to use with the BO.