LOTUSSCRIPT /COM/OLE のクラス
例:InViewEdit イベント
1. 次の InViewEdit イベントは、編集可能な列がすべて Text であり、同じ方法で処理されるビューで発生します。ユーザーは列エントリを編集します。編集した列エントリはコードにより検証されます。エントリに空の文字列は指定できません。ユーザーが編集可能な列エントリからクリックして移動するとき、または行の編集可能な列エントリすべてから [Tab] キーで移動するとき、このコードは ColProgName および ColumnValue 配列の編集可能な列エントリを基になる文書に書き込みます。
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
%REM
In this view, the programmatic name of each editable column
is the same as the name of the field whose value it holds.
All the fields for the editable columns are simple Text.
Each editable column gets the same processing.
%END REM
REM Define constants for request types
Const QUERY_REQUEST = 1
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
REM Define variables
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim caret As String
REM Get the CaretNoteID - exit if it does not point at a document
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub
REM Get the current database and document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
REM Select the request type
Select Case Requesttype
Case QUERY_REQUEST
REM Reserved - do not use in Release 6.0
Case VALIDATE_REQUEST
REM Cause validation error if user tries to exit column with no value
If Fulltrim(Columnvalue(0)) = "" Then
Messagebox "You must enter a value",, "No value in column"
Continue = False
End If
Case SAVE_REQUEST
REM Write the edited column view entries back to the document
For i = 0 To Ubound(Colprogname) Step 1
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
Case NEWENTRY_REQUEST
REM Create document and create "Form" item
REM Write column values to the new document
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main")
For i = 0 To Ubound(Colprogname) Step 1
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
End Select
End Sub
2. 次の InViewEdit イベントは、Text または Numeric という 2 つの編集可能な列があるビューで発生します。それぞれの列の処理方法は一部異なるため、コードで区別しなければなりません。
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
%REM
This view has two editable columns:one Text and one Numeric.
The programmatic name of each editable column
is the same as the name of the field whose value it holds,
but the processing for each column is different.
%END REM
REM Define constants for request types
Const QUERY_REQUEST = 1
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
REM Define variables
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim caret As String
REM Get the CaretNoteID - exit if it does not point at a document
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub
REM Get the current database and document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
REM Select the request type
Select Case Requesttype
Case QUERY_REQUEST
REM Reserved - do not use for Release 6.0
Case VALIDATE_REQUEST
REM Write message and cause validation error if ...
Select Case Colprogname(0)
Case "FieldText"
REM ... user tries to exit text column with no value
If Fulltrim(Columnvalue(0)) = "" Then
Messagebox "You must enter a value",, "No value in column"
Continue = False
End If
Case "FieldNumeric"
REM ... value in numeric column is non-numeric or negative
If Isnumeric(Columnvalue(0)) Then
If Cint(Columnvalue(0)) < 0 Then
Messagebox "Value must be greater than 0",, "Negative value"
Continue = False
End If
Else
Messagebox "Value must be numeric",, "Non-numeric value"
Continue = False
End If
End Select
Case SAVE_REQUEST
REM Write the edited column view entries back to the document
For i = 0 To Ubound(Colprogname) Step 1
Select Case Colprogname(i)
REM Write text entry back to document
Case "FieldText"
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
REM Write converted numeric entry back to document
Case "FieldNumeric"
Call doc.ReplaceItemValue(Colprogname(i), Cint(Columnvalue(i)))
End Select
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
Case NEWENTRY_REQUEST
REM Create document and create "Form" item
REM Write column values to the new document
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main")
For i = 0 To Ubound(Colprogname) Step 1
Select Case Colprogname(i)
REM Write text entry to document
Case "FieldText"
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
REM Write converted numeric entry to document
Case "FieldNumeric"
Call doc.ReplaceItemValue(Colprogname(i), Cint(Columnvalue(i)))
End Select
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
End Select
End Sub
3. 次の InViewEdit イベントは、1 番目の例と類似しています。ただし、列のプログラム名が列に関連付けられたアイテムとは異なります。したがって、このコードでは各列を調べないと、適切なアイテムを処理できません。
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
%REM
In this view, all the fields for the editable columns are simple Text.
Each editable column gets the same processing.
But the programmatic names of the columns are not the same
as the field names, so you have to case the names.
%END REM
REM Define constants for request types
Const QUERY_REQUEST = 1
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
REM Define variables
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim caret As String
REM Get the CaretNoteID - exit if it does not point at a document
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub
REM Get the current database and document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
REM Select the request type
Select Case Requesttype
Case QUERY_REQUEST
REM Reserved - do not use in Release 6.0
Case VALIDATE_REQUEST
REM Cause validation error if user tries to exit column with no value
If Fulltrim(Columnvalue(0)) = "" Then
Messagebox "You must enter a value",, "No value in column"
Continue = False
End If
Case SAVE_REQUEST
REM Write the edited column view entry back to the document
For i = 0 To Ubound(Colprogname) Step 1
Select Case Colprogname(i)
Case "ColumnOne"
Call doc.ReplaceItemValue("FieldOne", Columnvalue(i))
Case "ColumnTwo"
Call doc.ReplaceItemValue("FieldTwo", Columnvalue(i))
Case "ColumnThree"
Call doc.ReplaceItemValue("FieldThree", Columnvalue(i))
End Select
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
Case NEWENTRY_REQUEST
REM Create document and create "Form" item
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main")
For i = 0 To Ubound(Colprogname) Step 1
REM Write the edited column view entry back to the document
Select Case Colprogname(i)
Case "ColumnOne"
Call doc.ReplaceItemValue("FieldOne", Columnvalue(i))
Case "ColumnTwo"
Call doc.ReplaceItemValue("FieldTwo", Columnvalue(i))
Case "ColumnThree"
Call doc.ReplaceItemValue("FieldThree", Columnvalue(i))
End Select
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
End Select
End Sub
4. 次の InViewEdit イベントは、編集可能な列を 1 つ持つビューで発生します。したがって、処理する必要があるのは ColProgName および ColumnValue 配列の最初の要素だけです。列はリストボックスフィールド用であるため、リストボックスのいずれかの値の入力が確認コードにより求められます。
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
%REM
This view has one editable column, which is for a list box item.
%END REM
REM Define constants for request types
Const QUERY_REQUEST = 1
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
REM Define variables
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim ws As New NotesUIWorkspace
Dim caret As String
REM Define allowed values for list box
Dim elements(4) As String
elements(0) = "red"
elements(1) = "green"
elements(2) = "blue"
elements(3) = "yellow"
REM Get the CaretNoteID - exit if it does not point at a document
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub
REM Get the current database and document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
REM Select the request type
Select Case Requesttype
Case QUERY_REQUEST
REM Reserved - do not use for Release 6.0
Case VALIDATE_REQUEST
REM Cause validation error if user tries to exit column with no value
If Fulltrim(Columnvalue(0)) = "" Then
Messagebox "You must enter a value",, "No value in column"
Continue = False
End If
REM Or enters a value that is not in the list box
Dim flag As Boolean
flag = False
Forall element In elements
If Lcase(element) = Lcase(Columnvalue(0)) Then
flag = True
Exit Forall
End If
End Forall
If Not flag Then
Dim msg As String
Forall element In elements
msg = msg & element & Chr(10)
End Forall
Messagebox msg,, "Value must be one of the following"
continue = False
End If
Case SAVE_REQUEST
REM Write the edited column view entry back to the document
Call doc.ReplaceItemValue(Colprogname(0), Columnvalue(0))
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
Case NEWENTRY_REQUEST
REM Create document and create "Form" item
REM Write column value to the new document
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main")
Call doc.ReplaceItemValue(Colprogname(0), Columnvalue(0))
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
End Select
End Sub
5. 次の InViewEdit イベントは、値をアイコンとして表す編集可能な列が 1 つあるビューで発生します。このコードは、2 つのうちいずれかの値を、行によって表された文書に書き込むことでフィールドを処理します。これにより、2 つのアイコンを切り替えることができます。
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
%REM
This view has one editable column, which is for a list box item.
%END REM
REM Define constants for request types
Const QUERY_REQUEST = 1
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
REM Define variables
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim ws As New NotesUIWorkspace
Dim caret As String
REM Get the CaretNoteID - exit if it does not point at a document
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub
REM Get the current database and document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
REM Select the request type
Select Case Requesttype
Case QUERY_REQUEST
REM Reserved - do not use for Release 6.0
Case VALIDATE_REQUEST
REM Not used for icon columns
Case SAVE_REQUEST
REM Toggle value and write back to the document
If doc.GetItemValue(Colprogname(0))(0) = "OK" Then
Call doc.ReplaceItemValue(Colprogname(0), "NotOK")
Else
Call doc.ReplaceItemValue(Colprogname(0), "OK")
End If
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
Case NEWENTRY_REQUEST
REM Create document and create "Form" item
REM Write column value to the new document
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main")
Call doc.ReplaceItemValue(Colprogname(0), "OK")
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
End Select
End Sub
関連項目
InViewEdit イベント
用語集
フィードバック
ヘルプ
または
プロダクトユーザビリティ
ヘルプの使い方
すべてのヘルプ項目
用語集