Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Created: 22/09/2008
Last Updated: 22/09/2008
Suggested By: Warwick Black
Applies To:
CitectSCADA 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
CitectHMI 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
CitectFacilities 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
CitectSCADA Batch 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
CitectSCADA Pocket 5.31, 5.40, 5.41, 5.42, 5.50, 6.0, 6.1, 7.0
Summary:
How do I create a combo box?
Solution:
There are 2 ways to do it, Use:
Paste the activeX control “Microsoft Forms 2.0 ComboBox” on a graphics page
Associate the TEXT property with a Tag. This tag will contain the value of the item selected from the ComboBox.
FUNCTION MyPageLoad()
OBJECT oComboBox1
INT iIndex
oComboBox1 = ObjectByName("AN210")
_ObjectCallMethod(oComboBox1,"Clear")
_ObjectCallMethod(oComboBox1,"AddItem","Tag1",iIndex)
iIndex = iIndex + 1
_ObjectCallMethod(oComboBox1,"AddItem","Tag2",iIndex)
iIndex = iIndex + 1
_ObjectCallMethod(oComboBox1,"AddItem","Tag3",iIndex)
END
FUNCTION MyPageLoad2()
OBJECT oComboBox1
INT iIndex
oComboBox1 = ObjectByName("AN210")
_ObjectCallMethod(oComboBox1,"Clear")
_ObjectCallMethod(oComboBox1,"AddItem",Tag1,iIndex)
iIndex = iIndex + 1
_ObjectCallMethod(oComboBox1,"AddItem",Tag2,iIndex)
iIndex = iIndex + 1
_ObjectCallMethod(oComboBox1,"AddItem",Tag3,iIndex)
iIndex = iIndex + 1
END
FUNCTION LoadRecipe2ComboBox(STRING sAN)
STRING sName;
OBJECT oComboBox1;
INT iComboBoxIndex1 = 0;
INT iRecNo;
IF hRecipe < 0 THEN
hRecipe = DevOpen("Recipes", 0);
END
IF hRecipe >= 0 THEN
iRecNo = DevRecNo(hRecipe); !Current Record Number
DevSeek(hRecipe, 1);
oComboBox1 = ObjectByName(sAN);
_ObjectCallMethod(oComboBox1, "Clear");
WHILE NOT DevEOF(hRecipe) DO
sName = DevGetField(hRecipe, "Name");
_ObjectCallMethod(oComboBox1, "AddItem", sName,
iComboBoxIndex1);
iComboBoxIndex1 = iComboBoxIndex1 + 1;
DevNext(hRecipe);
END
DevSeek(hRecipe, iRecNo); // Reinstate the original position
ELSE
Message("ComboBox", "Cannot Open Recipes.DBF device.", 0);
END
END
If you want to use the function with other applications, you should modify it accordingly. For example, if you have more than
one ComboBox on a page, you could code the function as generic one as shown below. Simply pass the device handle,
animation point number and data field name. Note that you want the function to be call on page entry, you have to delay the
call until the control is instantiated. In V6, a new page event called "On page shown" is introduced that guarantee all objects
are instantiated. Hope this would help.
FUNCTION LoadRecipe2ComboBox(INT hRecipe, STRING sAN, STRING sFieldName)
STRING sName;
OBJECT oComboBox1;
INT iComboBoxIndex1 = 0;
INT iRecNo;
IF hRecipe >= 0 THEN
iRecNo = DevRecNo(hRecipe); !Current Record Number
DevSeek(hRecipe, 1);
oComboBox1 = ObjectByName(sAN);
_ObjectCallMethod(oComboBox1, "Clear");
WHILE NOT DevEOF(hRecipe) DO
sName = DevGetField(hRecipe, sFieldName);
_ObjectCallMethod(oComboBox1, "AddItem", sName,
iComboBoxIndex1);
iComboBoxIndex1 = iComboBoxIndex1 + 1;
DevNext(hRecipe);
END
DevSeek(hRecipe, iRecNo); // Reinstate the original position
ELSE
Message("ComboBox", "Cannot Open Recipes.DBF device.", 0);
END
END
Keywords:
Related Links
Attachments