{}

我们的品牌

欢迎访问施耐德电气网站

欢迎访问我们的网站。
搜索常见问题解答
怎样在Citect上使用Combobox控件?
问题描述:
怎样在Citect上使用Combobox控件?

所属产品线:
AVEVA™ Plant SCADA

解决方法:

There are 2 ways to do it, Use:

* ActiveX combo box, or
* ciText.combobox.

To use an ActiveX combo box:

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

To use a ciText combo box:

1.    Use example project

2.    Paste the following function to Recipe.Ci file

3.    Configure a device using DBF file type (as we are using Example project, Recipe.dbf already exists)

4.    Insert CiText.ComboBox on a graphics page (Say page "Recipe")

5.    Find out the animation point occupied by this control

6.    Add a button on this page as well and call the following function in the command field LoadRecipe2ComboBox("AN35")

7.    Compile the project

8.    Run the project

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



是否有帮助?

探索更多
范围:
探索更多
范围: