rtLib — Notes Rich Text Management Library Documentation of rtLib — Notes Rich Text Management Library Download rtLib — Notes Rich Text Management Library FAQ of rtLib — Notes Rich Text Management Library Purchase rtLib — Notes Rich Text Management Library Feedback about rtLib — Notes Rich Text Management Library


Table processing - tabbed table

Start search Mail feedback Back to Description

rtTableStyle rtRowDisplayStyle rtBorderStyle rtColor rtTable rtButton rtLabel

add (rtContainer) addNewLine (rtContainer) addNewLine (rTextParagraph) Add (rtCollection) Add (rTextParagraph) AltColor Border BorderStyle (rtBorderStyle) BorderStyle (rtTable) BorderStyle (rtTableStyle) BorderWidths Cells Collection (rtContainer) Collection (rtEnumeration) Color (rtBorderStyle) Color (rtFontstyle) Color (rtTableStyle) ColorStyle ColumnSpacing DropShadowWidth Font (rtButton) Font (rtLabel) Font (rtStyle) FontSize getRichTextItem getText (rtContainer) Green InnerBorderColor MinRowHeight RowDisplay Rows setRGB Style (rtContainer) TableID TableLayout TabPosition TabsWithFieldDriven useBorderColor Viewer

Code fragment from sample "Table processing - tabbed table"; see full running samples in downloadable help.
Dim style as rtStyle, tableBasic as rtTableStyle, rowDisplay as rtRowDisplayStyle
Dim borderStyle as rtBorderStyle ' these are just defined for indexer to find references to the classes/methods used

' define font style for table labels
Dim labelfont as New rtFontStyle (0)
set labelfont.Color = New rtColor(COLOR_RED)
labelfont.Color.setRGB cint(255*rnd), cint(255*rnd), cint(255*rnd) ' random color
labelfont.FontSize = 15

call ctxDump.getRichTextItem(doc,"Body")
' get the table
Set coll = ctxDump.Collection (PARSE_GROUP_TABLE)' this parses and retrieves the tables
dim table as rtTable, table2 as rtTable, o as variant, tabs as string, i as Integer, j as integer
dim RowStyle as rtRowDisplayStyle

set table = coll.getFirstElement' we just have one table - otherwise we need to work through the collection

ctxDump.Collection PARSE_GROUP_TEXT' just call it so we can obtain text from the cells
With table
.rows (1).TabLabel = ""
.rows (2).TabLabel = strRight(table.cells(2,2).getText, CRLF)' every cell starts with paragraph break
.rows (3).TabLabel = strRight(table.cells(3,2).getText, CRLF)
.rows (4).TabLabel = strRight(table.cells(4,2).getText, CRLF)

.Style.RowDisplay.Viewer = CDTABLEVIEWER_TABS
.Style.RowDisplay.TabPosition = TAB_POSITION_TOP
.Style.RowDisplay.TabsWithFieldDriven = True' allows both programmatic and manual switching
.tableID = "robert"' $robert will be field to set the selected tab
Set .Style.Font = labelfont ' starting version 1.5 rtLib allows to set label style
End With

' * let's implement programmatic switching; click on button cycle through the tab labels
' * we can do it (set field) even if the doc is in read mode
dim button as new rtButton(0)
Set button.Label = new rtLabel("Cycle Tabs")
tabs=table.rows (2).TabLabel &"#" &table.rows (3).TabLabel &"#" &table.rows (4).TabLabel

.formula = |list:=@explode("| &tabs &|";"#"); | &_
|FIELD cnt:=@if(cnt="";@elements(list);@Modulo(cnt +1; @elements(list))+1);label:=@subset(@subset(list;cnt);-1); | &_
|FIELD $robert:=label;@Command([RefreshHideFormulas]);""|
ctxDump.add button

' lets create a similar table
set table1 = new rtTable(2,2)
for i=1 to 3
for j=1 to 3
set table1.Cells(i,j) = table.Cells(i+1,j)' ommit first row
Next j
Next i
' make some looks
dim tabStyle as rtTableStyle

set tabStyle = table1.Style.TableLayout
tabStyle.ColorStyle = CDTABLE_LEFT
Set tabStyle.Color = New rtColor(0)
tabStyle.Color.setRGB 255,0,100
tabStyle.AltColor.Green = 200' both other are 0 by default
' table borders (cell borders may be set separately)

tabStyle.BorderStyle = CDTABLE_3D_BORDER_EMBOSS
'set table1.style.Border.Color = new rtColor(0)' it ignores color?
'table1.style.Border.Color.setRGB 200,100,0

table1.style.Border.BorderWidths = 10
table1.style.Border.dropShadowWidth = 12
tabStyle.InnerBorderColor.setRGB 54,106,182

ctxDump.addnewLine 1
ctxDump.add table1