Group: Forum Members
Posts: 2K,
Visits: 6.6K
|
Hi Edhy,
I agree that a subclass would be a good way to go. I just wanted to do a proof of concept, to show how it could work. Another way to do it would be to make a component that has this code. Then you could just add the component to a form were you needed it, set a combo property and you're good to go. Thus you could add this to existing combos without having to change them. However, it could get complicated as you'd need to generalize how to determine active/inactive (or whatever state that is needed) based on an arbitrary BO(s) and field(s). I'd probably wait until I'd done this a couple of times before attempting that.
I'm not sure how much I like this approach (disabling selection, changing display of active/inactive items), myself (just wondered how it could be done). Showing only those valid items when adding seems like a good approach, as it doesn't confuse the user with old data. However, it gets complicated during edits, as you need the inactive values in the combo because they might already be assigned, but you don't want the user to be able to change to another inactive value. It also could be confusing that the user can't select some values. I'd probably provide an optional message indicating why they can't select an inactive item. I also noticed that the font/style of the text of the combo isn't affected by DrawItem. I'd probably also handle setting the font if the combo based on if the item is active or inactive.
In any case, lots of ideas on how to get this done at least!
|