By publishing choices, one DTC can share information with other DTCs in a document such as a Web page in the Visual InterDev HTML editor. Your DTC may need a choice that is valid for an extended period of time or temporarily. To accommodate this situation, DTCs can share information either statically or dynamically. Static choices are for an extended time and dynamic choices are temporary.
Static choices can exist as a choice property on the site or as set of published choices stored in a Choices collection on the engine. Static means that the choice exists for an extended time but the properties of the choice can change. To publish a static choice, call the AddChoice or AddPopUpChoice methods on the Choices collection of the IDesignTimeControlSite. Static choices remain in effect until removed by a call to the Revoke method or until the document using the DTC is closed.
Choices published statically are the most efficient, and publishing statically is recommended. For an example of how static choices are used, see the Choices Walkthrough in Visual Basic and the Visual Basic sample project.
Dynamic choices are regenerated each time they are needed and disappear if they are not subscribed to by a DTC. To publish dynamic choices, call the AddChoice method directly on the temporary Choices collection passed to the OnGetChoices method. The collection is zero-based: once the rebind is over, dynamic Choices are discarded unless a ChoiceSink is bound to them. For an example of publishing dynamically, see The Query Builder Walkthrough and the Visual Basic sample project.
Dynamic choices are less efficient and can be difficult to use. They are appropriate if the source of the choices is constantly changing asynchronously. For example, dynamic choices might be useful if choices are based on something within the file system.
You can use a Choices collection in the following ways:
After you have published choices, your other DTCs can subscribe to them. See Subscribing to Choices.