The following tasks are associated with using an
ICollectionViewComboBox* part in visual composition. Tasks that
are common to many parts are described in related topics.
-
- Setting the combination box type
- To specify the combination box type, open the style
property in the ICollectionViewComboBox* property sheet.
Then, set one of the following styles on and set
the others off:
- dropDownType for a drop-down combination
box with an editable entry field
- readOnlyDropDownType for a drop-down
combination box with a read-only entry field
- simpleType for a combination box that
always displays the list box
The default style sets the simpleType style on.
- Setting the collection type
- To specify the type of collection containing the objects,
select Change Template Arguments from the part
pop-up menu. Then, in the Change Template Arguments
window, set the class Collection property. Enter
the type you want in the value column. The default
collection type is IVSequence.
- Setting the collection object type
- To specify the type of objects in the collection, select Change
Template Arguments from the part pop-up menu. Then,
in the Change Template Arguments window, set the class
Element property. Enter a pointer to the part type
(part type and *) in the value column.
- Defining strings for collection objects
- To produce strings that represent collection objects in
the combination box, specify a string generator that
provides the strings. To specify the string generator,
open the ICollectionViewComboBox* property sheet. Then,
enter code in the code prompter for the value column of
the stringGenerator property.
- If you implement an asString function, use
IStringGeneratorasString. Enter code similar to
the following: IStringGenerator
<itemType> (new IStringGeneratorasString
<itemType>)
- If you implement your own string generator, use
it instead of IStringGeneratorasString.
- Setting initial contents
- To define initial selection choices for the combination
box, connect a collection containing the choices to the
combination box. The combination box provides a view of
the collection. The contents of the collection determine
the contents of the combination box.
Specifically,
connect the this attribute of the collection part
to the items attribute of the
ICollectionViewComboBox* part. You must use a collection
part that has one template argument, such as an
IVSequence* part.
- Setting the initial choice
- To define a default selection for the combination box,
set the selectedCollectionPosition property in the
ICollectionViewComboBox* property sheet. Specify the
1-based index of the selection in the value column. The
corresponding choice in the collection part is the
default selection.
- Getting the selected choice
- To copy the selected object to a target that expects an
object of the type listed in the combination box, connect
the ICollectionViewComboBox* selectedElement
attribute to the target's this attribute. For
example, if you are listing ICustomer* objects, connect
the ICollectionViewComboBox* selectedElement
attribute to an ICustomer* attribute or parameter.
To
copy the text string for the selected object to an entry
field, do the following:
- Add a Variable part to the free-form surface and
change its type to the part type of the object
displayed in the combination box.
- Connect the ICollectionViewComboBox* selectedElement
attribute to the Variable this attribute.
- Connect the displayed text feature of the part in
the Variable to the IEntryField* text
attribute.
For example, if you are listing ICustomer* objects by
customer name, connect the ICollectionViewComboBox* selectedElement
attribute to a Variable part that holds an ICustomer*
part. Then, connect the Variable name attribute to
the IEntryField* text attribute.
- Adding a choice
- To add a new object to the combination box, add the
object to the collection part that contains the objects.
Use an add action for the collection type.
For
example, if you are using an IVSequence* collection, you
can use the IVSequence* add, addAsFirst, addAsLast
or addAtPosition action to add the object to the
collection. If you want to add the object at the position
of the currently selected object, connect the
ICollectionViewComboBox* selection attribute to
the connection or action requiring the position
parameter.
- Removing a choice
- To remove an object from the combination box, remove the
object from the collection part that contains the
objects. Use a remove action for the collection type.
For
example, if you are using an IVSequence* collection, you
can use the IVSequence* removeFirst, removeLast
or removeAtPosition action to remove the object
from the collection. If you want to remove the currently
selected object, connect the ICollectionViewComboBox* selection
attribute to the connection or action requiring the
position parameter.