How do I set the margin for the second column?

Hello,

I have a agent displays data in two columns. The problem is: The second column relies on the first column. So if the data in the first column is then the second column will be shifted to the left handside, and if the first column is long, then it’ll be shifted to the right handside. How do I set the fixed margin for the second column? How can I fix this issue?

====================================

…Some of declarations below are not needed in for this agent…

====================================

Dim uiwSource As NotesUIWorkspace

Dim nsSource As NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim view As NotesView

Dim vc As NotesViewEntryCollection

Dim entry As NotesViewEntry

'Dim doc As NotesDocument

Dim SendDoc As NotesDocument

'Dim curdoc As NotesDocument

Dim amat_db As NotesDatabase

Dim amat_doc As NotesDocument

Dim amat_lookupview As notesview

Dim ecp_db As NotesDatabase

Dim ecp_doc As NotesDocument

Dim ecp_lookupview As notesview

Dim nrtiNotice As NotesRichTextItem

Dim servername As String

Dim agentlog As NOTESLOG

Dim iDocs As Integer

Dim richStyle As NotesRichTextStyle

Dim compare_doc As NotesDocument

Dim ListName As Variant

Dim ListNameNotFound () As Variant, ListNametFound () As Variant

Dim iNotFound As Integer, iFound As Integer

Dim rtpStyle As NotesRichTextParagraphStyle

Dim ecp_admin As Variant, amat_admin As Variant

Dim aACounter As Integer, eACounter As Integer

Dim aCn () As String, eCn () As String

Dim eAdmin As NotesName, aAdmin As NotesName

Dim eLoop As Integer, aLoop As Integer

Dim x As Integer, y As Integer

Dim iamat As Integer

Dim aTemp As String

====================================

Sub Initialize

Dim session As New NotesSession

Dim nisource As NotesItem

Dim nisource1 As NotesItem

Dim nrtiNoticeParaStyle As NotesRichTextParagraphStyle

Dim nrtiNoticeTextStyle As NotesRichTextStyle



On Error Goto Quit



Set agentlog = New NOTESLOG( "SET MARGIN AGENTS")

Call agentlog.OPENAGENTLOG

Call agentLog.LogAction("Started:  " & Time$())

	

servername="XXXX"

Set ecp_db=New notesdatabase(servername, "XXXX.nsf")

Set ecp_lookupview = ecp_db.GetView("XXXX")

Set amat_db=New notesdatabase(servername, "XXXXX.nsf")

Set amat_lookupview = amat_db.GetView("XXXXX")

Set compare_doc = ecp_lookupview.GetFirstDocument

Set SendDoc = New NotesDocument(ecp_db)

Set nrtiNotice = New NotesRichTextItem(SendDoc, "Body")

Set nrtiNoticeParaStyle = Session.CreateRichTextParagraphStyle

Set nrtiNoticeTextStyle = Session.CreateRichTextStyle

nrtiNoticeTextStyle.FontSize = 10



Dim pos As Long

Dim interval As Long

pos = RULER_ONE_INCH

interval = RULER_ONE_CENTIMETER



iNotFound = 0

iFound = 0

iamat = 0

iDocs = 0



Dim acl As NotesACL

Dim aclEntry As NotesACLEntry

Dim ntfy_DbAdmin() As String

Dim ntfy_SuperAdmin() As String	

Dim RoleFound As Boolean, SaFound As Boolean

Dim i As Integer, j As Integer

i = 0

j = 0

Set acl = ecp_db.ACL

Set aclEntry = acl.GetFirstEntry



RoleFound = False

Do Until aclEntry Is Nothing

	If aclEntry.IsRoleEnabled( "[DbAdmin]" ) Then

		RoleFound = True

		i = i + 1

		Redim Preserve ntfy_DbAdmin(i)			

		ntfy_DbAdmin(i) = aclEntry.Name

	End If

	Set aclEntry = acl.GetNextEntry( aclEntry )

Loop



If RoleFound Then

	Set niSource = New NotesItem(SendDoc, "SendTo", ntfy_DbAdmin)

Else

	Set niSource = New NotesItem(SendDoc, "SendTo", "XXXXXX" )

End If



nrtiNoticeParaStyle.LeftMargin = RULER_ONE_INCH

Call nrtiNotice.AppendText("Dear XXX, ")

Call nrtiNotice.AddNewLine(2)

Call nrtiNotice.AppendText("this is a test...")	

Call nrtiNotice.AddNewLine(2)	

Call nrtiNotice.AddTab(1)

nrtiNoticeTextStyle.Bold = True

nrtiNoticeTextStyle.Underline = True

Call nrtiNotice.AppendStyle(nrtiNoticeTextStyle)

Call nrtiNotice.AppendText("Column 1")

nrtiNoticeParaStyle.LeftMargin = RULER_ONE_INCH * 4.0

Call nrtiNotice.AddTab(3)

Call nrtiNotice.AppendText("Column 2")

nrtiNoticeTextStyle.Bold = False

nrtiNoticeTextStyle.Underline = False

Call nrtiNotice.AppendStyle(nrtiNoticeTextStyle)

Call nrtiNotice.AddNewLine(1)



'The columns are aligned when they're printed out.

'It's because of the length of the data value.



While Not (compare_doc Is Nothing)

	iDocs = iDocs + 1

	ListName = compare_view.ColumnValues(0)

	If ListName <> "" Then

		If (compare_view.HasItem("RQ_Status")) Then

			If compare_view.GetItemValue("RQ_Status")(0) = "InActive" Then

				Set amat_doc=amat_lookupview.GetDocumentByKey(ListName)

				If Not (amat_doc Is Nothing) Then

					Call nrtiNotice.AddNewLine(1)	

					Call nrtiNotice.AddTab(1)

					Call nrtiNotice.AppendDocLink(compare_view, ListName, ListName)

					Call nrtiNotice.AddTab(3)

					Call nrtiNotice.AppendDocLink(amat_doc, ListName, ListName)

					Call nrtiNotice.AddNewLine(1)	

					Set niSource = New NotesItem(SendDoc, "SendTo", ntfy_DbAdmin)

				End If

			End If	

		End If					

	End If

	Set compare_doc = ecp_lookupview.GetNextDocument(compare_doc)		

Wend	



Call nrtiNotice.AppendParagraphStyle(nrtiNoticeParaStyle)			'<=================	

Call nrtiNotice.AddNewLine( 2, True )

Call nrtiNotice.AppendText("Best Regards,")

Call nrtiNotice.AddNewLine( 3, True )

Call nrtiNotice.AppendText(ecp_db.Title + " Database")

Call nrtiNotice.AddNewLine( 2, True )



Set richStyle = Session.CreateRichTextStyle

richStyle.FontSize = 7

Call nrtiNotice.AppendStyle(richStyle)

Call nrtiNotice.AppendText("This is a test")

richStyle.Bold = True

Call nrtiNotice.AppendStyle(richStyle)

Call nrtiNotice.AppendText("This is another message")

richStyle.Bold = False

Call nrtiNotice.AppendStyle(richStyle)

Call nrtiNotice.AppendText("This is another message...")

Call nrtiNotice.AddNewLine( 1, False )	

Call nrtiNotice.AddNewLine(1)



SendDoc.Form = "Memo"

SendDoc.Principal = ecp_db.Title

SendDoc.From = SendDoc.Principal(0)



Call SendDoc.ReplaceItemValue("Subject", "Values in Columns" )

Call SendDoc.Send(False)

	

Call agentLog.LogAction("Ended: " & Str(iDocs))

If Not ( agentLog Is Nothing ) Then

	Call agentlog.CLOSE

End If        



Exit Sub	

Quit:

Msgbox Error & " at line: " & Erl	

End Sub

====================================

Thanks for your help.

Mike Woo

Subject: How do I set the margin for the second column?

The only way to make the width of the display independent of the length of the data is to use a table. The examples in the Designer Help section on the NotesRichTextTable class are a pretty good start.

Subject: RE: How do I set the margin for the second column?

Hello Stan,

Do you know how I can adjust the size of the cells and/or table? Also how can I position the table? I can’t find any example like that in the help file.

Thanks,

Mike Woo

Subject: Did you look at the NotesRichTextItem.AppendTable Help???

You would have noticed the last parameter?Call notesRichTextItem.AppendTable( rows%, columns% [, labels] [, leftMargin&] [, rtpsStyleArray] )

Parameters

rows%

Integer. Number of rows in the table.

columns%

Integer. Number of columns in the table.

labels

Array of type String. Optional. Text of labels for a tabbed table. The number of array elements must equal the number of rows. Omitting this parameter appends a basic table. Including this parameter appends a tabbed table.

leftMargin&

Long. Optional. Left margin of the table in twips. Defaults to 1440. The following constants are available:

RULER_ONE_CENTIMETER (567)

RULER_ONE_INCH (1440)

rtpsStyleArray

Array of type NotesRichTextParagraphStyle. Optional. Creates a table with fixed-width columns and style attributes as specified. Omitting this parameter creates an auto-width table. The array must contain one element for each column in the table in sequence. Explicitly set the first line left margin and left margin, which control the start of text relative to the start of the column, and the right margin, which controls column width.

Then you surely would have followed the link to the examples and found the following:

  1. This view action creates a basic table of 4 rows and 3 columns, and populates it. The width of each column is fixed at 1.5 inches. The left margin of the table is 1.5 inches.

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
Dim styles(1 To 3) As NotesRichTextParagraphStyle
For i% = 1 To 3 Step 1
Set styles(i%) = session.CreateRichTextParagraphStyle
styles(i%).LeftMargin = 0
styles(i%).FirstLineLeftMargin = 0
styles(i%).RightMargin = RULER_ONE_INCH * 1.5
Next
Call body.AppendTable _
(rowCount%, columnCount%, RULER_ONE_INCH * 1.5, styles)
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

Subject: RE: Did you look at the NotesRichTextItem.AppendTable Help???

Hi Bill,

I got this working around by using the Richtext for the tab.

Thanks for your help.

Mike Woo