How To Use Combo Boxes in Customized Forms
Thursday, July 31st, 2008Hi All,
In this article, I will explain how to use DataComboBox, DataStaticDataComboBox and ComboBox components for form customization.
If you wish to follow all steps one by one, please download the ComboBoxExamples package and copy it to the same folder where the “My Package.txg” file is. Possible path: Documents and Settings\{user name}\My Documents\Toad Data Modeler\Packages\{Guid}\ .
Then enable Expert mode via Settings | Options | General item and select the Expert Mode checkbox. Finally click the Expert Mode item and clear the Save the definitions to ‘My Package’ package checkbox and restart Toad Data Modeler.
Let’s say we have a simple model with three entities, one stored procedure and one synonym.

In order to modify the form, we have to edit the existing synonym, right-click the form and select Customize Form as…
As you can see, there are four new items on the form.
- Entities (DataComboBox) - this item allows you to select entity from a list of entities and assign its value to the system ‘Object’ combo box. We can pass objects to other objects of Dispatch type.
- DBLink (DataStaticComboBox) - this item will work as a replacement for the ‘Dblink’ field. We can pass values to other objects of String type.
- Last combo box on the form contains items that can be used for verification. We can define combo box with defined values, don’t store the values anywhere but use values for events, in this case for verification.

Select the ComboBoxesExample package.

Modified form in Edit mode will open.
DataComboBox
Click the DataComboBox item.

In Component Inspector, see properties:
- DataSource = Synonym
- DataList = Entities (here we can select lists of objects)
- DisplayPropertyName = Name (here we can select any property of Entity object)
- DataField = Entity (property of type Dispatch)
DataComboBox should be used whenever you need to select an item from a list of existing objects and fill property of Dispatch type.
DataStaticComboBox
Click the DataStaticComboBox item.

In Component Inspector, see properties
- DataSource = Synonym
- DataField = Dblink (property of type String)
- Items = defined list. Click the IDispatch item and press F2. Then click the three dots button to open appropriate dialog where you can manually specify the values.
DataStaticComboBox should be used whenever you need to select an item from predefined list fill property of String type.
ComboBox and Events
Click the last combo box on the form.

In Component Inspector, see properties:
- Items = defined list of items. Click the IDispatch item and press F2. Then click the ‘…’ button to open appropriate dialog where you can specify values manually.
The simple ComboBox component should be used in combination with defined Events. Click the Verification button and see its name in Component Inspector.

The name is BtnExample. It is important to know the name becase event name must be formed as a combination of component name and event name. In our case, we will need a script that will contain BtnExampleOnClick function. Using this event we will be able to verify if object or entity has been assigned to the synonym. If we select ‘All’ from the last combo box and no object will be assigned, a message box with text “Nothing assigned ” will appear. Otherwise “Object assigned” or “Entity assigned” text will be displayed. Note: Remember to press Apply after changing values in Entity(DataComboBox).
Let’s see the definition of this script.

function BtnExampleOnClick()
{
var text = 'Nothing assigned ';
var Model = Synonym.Root();
var OrigSynonym = Model.Synonyms.GetObjectById( Synonym.Id );
// We need to read original object. 'Synonym' is only a temporary
// object (created when a form is edited) that that doesn't have
// all properties loaded/filled.
if (CBMSGDlg.Text == 'All')
{
if (OrigSynonym.Object!=null) text = 'Object is assigned';
}
else
{
if (OrigSynonym.Entity!=null) text = 'Entity is assigned';
}
System.ShowMessageDialog(1000,'Synonym Verification',text,3,4+8);
/* Opens new dialog
param1 - index of dialog for each dialog must be unique index
to implement the "Don't show again" function
param2 - Form name
param3 - Text of message
param4 - Type of dialog you can choose
Warning - 1
Error - 2
Information - 3
Confirmation - 4
Custom - 5
param5 - Buttons you can choose
1 - Yes
2 - No
4 - Ok
8 - Cancel
16 - Abort
32 - Retry
64 - Ignore
128 - All
256 - No to All
512 - Yes to All
1024 - Help
*/
}
MessageDialog
On line 17, you can see how to display MessageDialog via scripting.
Result:

That’s all. For more information about how to create a new package, how to create new scripts etc. please see out Toad Data Modeler Manual, section Customization | Customization Sample.
Regards,
Vaclav







