Originally posted by: pmclaughlin
When moving selected items using the up or down button the Add button greys out...even though I have items in the available list. Also, any item selected in the available list is no longer recognized as selected.
Anybody else see this?
ReplyOriginally posted by: Adrian Stanley
This is a good solution to a common problem - how to allow the user to choose from one or more alternatives.
An alternative solution is to use a single CListCtrl with the LVS_EX_CHECKBOXES style. Instead of Add and Remove buttons the user checks individual items in the list.
You could still have Add all and Remove All buttons, but they would check all the items in the list box and uncheck all the items in the list box, respectively (so you might want to call the buttons Check all and Uncheck all instead).
The Move up and Move down buttons would be replaced by drag & drop. This is the only tricky part of the implementation - unlike the other features it requires a far bit of bespoke code. However, I've just posted an article to CodeGuru "A Drag and Drop List Control" which demonstrates how to do drag and drop; this article should be appearing soon.
The obvious advantage of using a CListCtrl is you only need one list, and you get rid of 4 of the 6 buttons, quite a saving on screen real estate. The main disadvantage is that it requires at least version 4.7 of the common controls, as installed with IE 4 and above.
Another minor disadvantge is that CListCtrls are slightly harder to code that CListBoxes, mainly because a CListCtrl is a much more complex beast, and offers far more features. Even so, I would recommend for any new projects that you use CListCtrls instead of CListBoxes - you never know when you might need some of the new features, and the extra effort will have been worth it.
Reply