TheSwamp
Code Red => .NET => Topic started by: Dale Bartlett on March 08, 2011, 04:00:34 AM
-
Hi All,
This is my first post, so be gentle.
I wish to create a Table Style utilising Text Styles (fixed height) for each of the row types (Title, Header, Data). The Table Style is to be created ahead of generating the table, so row and column numbers are not fixed. I have scoured the web (and this site), but to no avail. With the new 2011 Row Inherit process, presumably I set one row in the style, but I can't find how to make a particular row type use a particular text style.
Many thanks and compliments to all contributers, I have only recently discovered this resource.
Regards, Dale
-
Welome to the Swamp!
Have you looked at TableStyle.SetTextStyle(ObjectId id, string styleName)
id = TextStyleTableRecord object ID
styleName = cell style name
If you need help implementing it please reply back.
-
Hi Jeff,
Thanks for the reply. I believe I have resolved it (not yet tested!!):
// Set text style
ts.SetTextStyle(textStyleTitleId, (int)RowType.TitleRow); // title row
ts.SetTextStyle(textStyleHeaderId, (int)RowType.HeaderRow); // header row
ts.SetTextStyle(textStyleDataId, (int)RowType.DataRow); // data row
// Set text alignment
ts.SetAlignment(CellAlignment.MiddleCenter, (int)RowType.TitleRow); // title row
ts.SetAlignment(CellAlignment.MiddleCenter, (int)RowType.HeaderRow); // header row
ts.SetAlignment(CellAlignment.MiddleLeft, (int)RowType.DataRow); // data row
Regards, Dale
Welome to the Swamp!
Have you looked at TableStyle.SetTextStyle(ObjectId id, string styleName)
id = TextStyleTableRecord object ID
styleName = cell style name
If you need help implementing it please reply back.
-
Hello, do not speak English
Public Sub Tb_CrtStl()
Dim nombre As String = GetString("Nombre del estilo:")
Dim mrgVrt As Double = GetDouble("Margen celda Vertical.")
Dim mrgHrz As Double = GetDouble("Margen celda Horizontal:")
Dim alTxTl As Double = GetDouble("Altura del texto del titulo.")
Dim alTxCab As Double = GetDouble("Altura del texto de las cabeceras.")
Dim alTxDt As Double = GetDouble("Altura del texto de los datos.")
Try
Dim styleName As String = nombre
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using tr As Transaction = doc.TransactionManager.StartTransaction()
Dim tsId As ObjectId = ObjectId.Null
Dim sd As DBDictionary = DirectCast(tr.GetObject(db.TableStyleDictionaryId, _
OpenMode.ForRead), DBDictionary)
' Comprobar si existe
If sd.Contains(styleName) Then
Application.SetSystemVariable("CTABLESTYLE", nombre)
Return
Else
' si no existe lo crea
Dim ts As New TableStyle()
ts.VerticalCellMargin = mrgVrt
ts.HorizontalCellMargin = mrgHrz
ts.SetTextHeight(alTxCab, RowType.HeaderRow)
ts.SetTextHeight(alTxTl, RowType.TitleRow)
ts.SetTextHeight(alTxDt, RowType.DataRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.TitleRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)
ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)
sd.UpgradeOpen()
tsId = sd.SetAt(styleName, ts)
tr.AddNewlyCreatedDBObject(ts, True)
sd.DowngradeOpen()
tr.Commit()
End If
End Using
Application.SetSystemVariable("CTABLESTYLE", nombre)
Return
Catch ex As Exception
Return
End Try
End Sub
-
bieres,
Nice code,
Gracias