I use this proceedure, but changes the case name to protect my source code. I had to work this out the 'hard way' by testing and probing every option one by one. Be nice if it was properly documented in a help file somewhere.
Public Function DefineTableStyle(ByVal strStyleName As String) As TableStyle
Dim ts As TableStyle = Nothing
Using trans As Transaction = db.TransactionManager.StartTransaction
Dim tsd As DBDictionary = trans.GetObject(db.TableStyleDictionaryId, OpenMode.ForWrite, True, True)
If tsd.Contains(strStyleName) Then
ts = tsd.GetAt(strStyleName).GetObject(OpenMode.ForWrite)
Else
ts = New TableStyle
tsd.SetAt(strStyleName, ts)
trans.AddNewlyCreatedDBObject(ts, True)
End If
Select Case strStyleName
Case "Ariel"
ts.HorizontalCellMargin = 1
ts.VerticalCellMargin = 5
Dim txtstyle As ObjectId = GetTextStyle("Ariel")
ts.SetTextStyle(txtstyle, RowType.TitleRow)
ts.SetTextStyle(txtstyle, RowType.HeaderRow)
ts.SetTextStyle(txtstyle, RowType.DataRow)
ts.SetTextHeight(8, RowType.TitleRow)
ts.SetTextHeight(6, RowType.HeaderRow)
ts.SetTextHeight(6, RowType.DataRow)
ts.SetAlignment(CellAlignment.MiddleLeft, RowType.TitleRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)
Case "Simplex"
ts.HorizontalCellMargin = 1
ts.VerticalCellMargin = 5
Dim txtstyle As ObjectId = GetTextStyle("Simplex")
ts.SetTextStyle(txtstyle, RowType.TitleRow)
ts.SetTextStyle(txtstyle, RowType.HeaderRow)
ts.SetTextStyle(txtstyle, RowType.DataRow)
ts.SetTextHeight(8, RowType.TitleRow)
ts.SetTextHeight(6, RowType.HeaderRow)
ts.SetTextHeight(6, RowType.DataRow)
ts.SetAlignment(CellAlignment.MiddleLeft, RowType.TitleRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)
Case "RomanC"
ts.HorizontalCellMargin = 6
ts.VerticalCellMargin = 6
Dim txtstyle As ObjectId = GetTextStyle("RomanC")
ts.SetTextStyle(txtstyle, RowType.TitleRow)
ts.SetTextStyle(txtstyle, RowType.HeaderRow)
ts.SetTextStyle(txtstyle, RowType.DataRow)
ts.SetTextHeight(6, RowType.TitleRow)
ts.SetTextHeight(6, RowType.HeaderRow)
ts.SetTextHeight(6, RowType.DataRow)
ts.SetAlignment(CellAlignment.MiddleLeft, RowType.TitleRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)
ts.IsHeaderSuppressed = True
ts.IsTitleSuppressed = True
Case "Standard"
'do nothing to it.
Case Else
End Select
trans.Commit()
End Using
Return ts
End Function
jvj