On Oct 4, 2006, at 2:06 PM, John J. Mihaljevic wrote:

        The Enabled state shouldn't change when the checkbox
doesn't change, so why do you need the code to fire?

I was having everything revert to Enabled for each new record that the user was adding. I was then going to disable certain fields depending on the value of the checkbox. I suppose I *could* leave the Enabled status of each field the same, rather than resetting them all to Enabled, but was wondering why the code wasn't firing when just "passing through" the checkbox rather
than actually clicking on it.

Ideally, this logic would belong in a business object, but let's take it one step at a time. Let's limit ourselves to doing this in the UI.

If the checkbox were bound to a value, either in a cursor or perhaps a form property, I would use that value, and not worry about the checkbox itself. Then I would create a method of the form that each control that needs to be enabled/disabled could call to determine its enabled status. Then in the Refresh() of those controls, have code like:

This.Enabled = Thisform.isItOK()
    - or -
This.Enabled = NOT Thisform.isItOK()

Now when you add a record, just call Thisform.Refresh(), and all the controls will enable/disable themselves as needed. In your checkbox's Valid(), add a call to Thisform.Refresh(), and the controls will automagically do the right thing without the checkbox knowing a thing about the logic involved, or even which other controls are affected.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to