0

所以我有一个按钮来显示我创建的列表框。这个列表框有一些附件,它填充了一些项目(附件)。此外,我创建了另一个按钮,我想删除我将从列表框中选择的项目。有没有简单的方法/公式可以做到这一点?提前致谢。

4

2 回答 2

2

请尝试更清楚地解释您要做什么。我假设“列表框”是指列表框类型的字段。这种字段不能包含附件,只能包含文本值。您的意思是列表框包含一个或多个附件的名称吗?

您谈论“显示列表框的按钮”。这与问题有关吗?

列表框是如何创建和填充的?我假设另一个字段包含附件的名称?

我使用了一些假设(您确实需要更详细地解释您的问题),这就是我解决它的方法:


字段“ListData”:文本字段,隐藏。包含您要显示的值(例如附件名称),以分号分隔。

字段'ListBox':列表框字段,允许多个值,文档刷新时刷新选择,使用公式进行选择:@Explode(ListData;";")

按钮“删除所选”:

Sub Click(Source As Button)
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim selected As Variant
    Dim listdata As Variant
    Dim files List As String
    Dim newlistdata As String
    Dim i As Integer

    Set uidoc = ws.CurrentDocument
    '*** Read the field values and split into arrays
    listdata = Split( uidoc.FieldGetText("ListData"), ";" )
    selected = Split( uidoc.FieldGetText("ListBox"), ";" )
    '*** Convert listdata array into a Lotusscript list
    Forall file In listdata
        files(file) = file
    End Forall
    '*** Loop through the array of selected values
    For i = 0 To Ubound(selected)
        '*** Check if the currently processed value is in the files list
        If Iselement(files(selected(i))) Then
            Erase files(selected(i))    ' Remove/erase from the list
            '*** Add code here to remove attachments from document
            '*** if that is what you actually want to do.
            '*** Use notesEmbeddedObject.Remove method for that.
        End If  
    Next
    '*** Now we have the files list with the selected items removed.
    '*** Loop though the list and build a string of remaining values
    Forall ff In files
        newlistdata = newlistdata + ff + ";"    
    End Forall
    '*** Write the new string of remaining attachments back to the listdata field
    Call uidoc.FieldSetText("ListData", newlistdata)
    Call uidoc.Refresh
End Sub

您只需要考虑问题并弄清楚您真正想要做什么,然后将其分解为更小的步骤,解决每个步骤,等等。Lotusscript 与其他语言没有什么不同,

注意:代码可能看起来很复杂并且比它必须的要长,因为我添加了大量的评论,所以你(希望)可以理解正在做什么......

于 2012-08-31T14:27:50.380 回答
0

1) 对列表框中的选项使用隐藏的多值字段。它的值将根据默认值(@Attachment 或另一个字段值)计算,并将删除另一个隐藏字段“已删除”(@Replace)中提到的所有值。

2)“已删除”字段将由您的“删除”按钮填充,例如

FIELD removed := @Trim(@Unique(removed:listbox));@All

“listbox”包含当前在列表框中选择的值。

3) 我建议提供一些关于已删除值和撤消/重置能力的反馈。

于 2012-08-30T09:38:52.900 回答