我有一个表单,其中包含两个名为“Field 1”和“Field 2”的字段以及一个名为“check”的操作按钮。单击该操作按钮,我想打开包含三个字段的对话框,这些字段应根据字段2值自动填充。如何实现呢?
感谢是否有人帮助我。
答案 0 :(得分:4)
是的,有可能。 document
有一个NotesUIWorkspace.DialogBox()
参数。使用此文档将参数传递给对话框。
<小时/>
<强>更新强>
假设您有一个名为“MyDialogForm”的表单来代表您的对话框。
它看起来像那个并包含3个字段:
你有一个包含两个字段的表单和“Check”按钮:
将以下代码放入“Check”按钮的“Click”事件处理程序:
Sub Click(Source As Button)
Const DIALOG_FORM_NAME = "MyDialogForm"
Dim ws As New NotesUIWorkspace
Dim dialogBoxAccepted As Boolean
Dim dialogParamDoc As NotesDocument
Dim currentDocument As NotesDocument
Dim field2Value As String
Set currentDocument = ws.CurrentDocument.Document
field2Value = currentDocument.GetItemValue("Field2")(0)
'document created in-memory, but should not be saved
Set dialogParamDoc = New NotesDocument(currentDocument.ParentDatabase)
'populating dialog box fields
Call dialogParamDoc.ReplaceItemValue("DialogField1", "dialogField1 with: " + field2Value)
Call dialogParamDoc.ReplaceItemValue("DialogField2", "dialogField2 with: " + field2Value)
Call dialogParamDoc.ReplaceItemValue("DialogField3", "dialogField3 with: " + field2Value)
dialogBoxAccepted = ws.DialogBox(DIALOG_FORM_NAME,True , True, False, False , False , False, "My Dialog Title", dialogParamDoc, True)
If dialogBoxAccepted Then
'displaying values, entered/changed in dialog box
Msgbox dialogParamDoc.getItemValue("DialogField1")(0),,"DialogField1"
Msgbox dialogParamDoc.getItemValue("DialogField2")(0),,"DialogField2"
Msgbox dialogParamDoc.getItemValue("DialogField3")(0),,"DialogField3"
End If
End Sub
此代码读取“Field2”并根据其值填充对话框字段。然后它会显示可以更改这些值的对话框。
如果在对话框中按下“确定”(接受对话框),代码将显示您在对话框中更改的值。