数据库中表单FORM中有一个AA的RTF域和BB域,请教
1:如何用代码在AA域中生成一个5行4列的表格
2:如何用代码设置表格的列标题
3:另外设置一个按钮,标题属性为增加一行,代码该如何写
谢谢
------解决方案--------------------
看看Notes帮助的例程吧。
1. This agent creates a document, creates a table in a rich text item in the document, saves the document, then gets the table and displays its properties.
%INCLUDE "lsconst.lss"
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
REM Create new document with rich text item
Dim doc As New NotesDocument(db)
Call doc.AppendItemValue("From", session.UserName)
Call doc.AppendItemValue("Form", "Main Form")
Call doc.AppendItemValue _
("Subject", Inputbox("Subject?"))
Dim rti As New NotesRichTextItem(doc, "Body")
Call rti.AppendText("Paragraph of text")
Call rti.AddNewLine(2)
REM Create a table
Dim rows As Integer, columns As Integer
rows = 4
columns = 3
Dim tabs() As String
If Messagebox("Do you want a tabbed table?", _
MB_YESNO + MB_ICONQUESTION, "Tabbed?") = IDNO Then
Call rti.AppendTable(rows, columns)
Else
Redim tabs(1 To rows)
For i = 1 To rows
tabs(i) = "Row " & i
Next
Call rti.AppendTable(rows, columns, tabs)
End If
REM Save the document
Call doc.Save(True, False)
REM Get the table
Dim rtnav As NotesRichTextNavigator
Set rtnav = rti.CreateNavigator
If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
Messagebox "Could not find table",, "Fatal error"
Exit Sub
End If
Dim rtt As NotesRichTextTable
Set rtt = rtnav.GetElement
labelString = ""
Forall label In rtt.RowLabels
If label <> "" Then labelString = labelString & Chr(13) & _
" " & label
End Forall
If labelString = "" Then labelString = "No labels"
Messagebox "Columns = " & rtt.ColumnCount & Chr(13) & _
"Rows = " & rtt.RowCount & Chr(13) & _
"Labels = " & labelString & Chr(13) & _
Style = " & rtt.Style & Chr(13) & _
"Color = " & rtt.Color.NotesColor & Chr(13) & _
"AlternateColor = " & rtt.AlternateColor.NotesColor _
,, "NotesRichTextTable"
End Sub
2. This view action creates a basic auto-width table of 4 rows and 3 columns, and populates it.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
REM Create document with Body rich text item
Dim doc As New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main topic")
Call doc.ReplaceItemValue("Subject", "Table 4 x 3")
Dim body As New NotesRichTextItem(doc, "Body")
REM Create table in Body item
rowCount% = 4
columnCount% = 3
Call body.AppendTable(rowCount%, columnCount%)
REM Populate table
Dim rtnav As NotesRichTextNavigator
Set rtnav = body.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
For iRow% = 1 To 4 Step 1
For iColumn% = 1 To 3 Step 1
Call body.BeginInsert(rtnav)
Call body.AppendText("Row " & iRow% & ", Column " & iColumn%)
Call body.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Next
Next
REM Save document and refresh view
Call doc.Save(True, False)
Dim ws As New NotesUIWorkspace
Call ws.ViewRefresh
End Sub
3. This agent gets the cells in the first table in an item and displays the first text paragraph in each cell.