将新选项添加到当前域的可用选择列表中。域必须为 ListFieldChoice 类型。
expression.AddChoice(text, Index)
expression 必选。返回 ListFieldChoice 对象的表达式。
text 必选。String 类型。代表将要出现在下拉列表中或单选按钮旁的文本。
Index 可选。Long 类型。代表选项在选项列表中的位置。
下列示例在活动站点第一个列表中的 NewChoiceField 选项域中添加两个选项。新选项为 SaleOption(将出现在列表的第一项)和 SaleOption2(将出现在列表的第二项)。选项的相对位置由可选的 Index 参数决定。
Sub AddChoice() 'Adds choices to the choice field Dim objApp As FrontPage.Application Dim objLstFlds As listFields Dim objFldChoice As ListFieldChoice Set objApp = FrontPage.Application Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields 'Reference new field and add to new choices to the list Set objFldChoice = objLstFlds.Item("NewChoiceField") objFldChoice.AddChoice text:="SaleOption1", Index:=1 objFldChoice.AddChoice text:="SaleOption2", Index:=2 End Sub