LotusScript - 如何以编程方式在多选ListBox中选择多个值

时间:2017-06-16 05:50:58

标签: listbox multi-select lotusscript

我正在尝试使用LotusScript在ListBox中选择值。 我的代码如下所示:

Forall role In docByUi.rolesList
        If entity.getRoles <> "" Then
            If Instr(1, entity.getRoles,role,5) Then
                resultRoles = resultRoles & role
            Else    
                resultRoles = resultRoles + Chr$(13) + Chr$(10)
            End If
        End If
    End Forall

    Call uiDoc.FieldSetText("rolesList", resultRoles)
    Call uiDoc.Refresh

但它不起作用。我尝试选择第一项时没有问题,但我不能选择多项。

我的列表框有两个项目(将来会更多): enter image description here

问题:

1。如何使用LotusScript选择ListBox项目?

2。如果项目数超过两个e.t.c,我该如何选择要选择的项目?

第3。能否请您提供一些关于此或任何建议的小例子......

谢谢!

1 个答案:

答案 0 :(得分:3)

请将变量[resultRoles]声明为数组。

Dim resultRoles As Variant

resultRoles = Split("") 'that will make variable array

Forall role In docByUi.rolesList
    If entity.getRoles <> "" Then
        If Instr(1, entity.getRoles,role,5) Then
            resultRoles = Arrayappend(resultRoles, role)
        End If
    End If
End Forall

resultRoles = Fulltrim(resultRoles) 'that will delete first empty element from array

Call uiDoc.Document.replaceitemvalue("rolesList", resultRoles) 'use NotesDocument instead
Call uiDoc.Refresh

这是一个干净的例子,在表格上我只有1个字段ListField,值为[a,b,c],1个按钮填充该字段。

Dim ws As New notesuiworkspace
Dim uidoc As NotesUIDocument
Dim a As Variant

Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document

a = Split("b;c", ";")
Call doc.replaceitemvalue("ListField", a)

Немазащо。