.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

setbackgroundcolor not working (table)

1 REPLY 1
Reply
Message 1 of 2
Anonymous
324 Views, 1 Reply

setbackgroundcolor not working (table)

Can someone tell me why, in the code below, that the row background color wont "take"?
everything else is working...

Thanks
Perry

Public Sub Style1(styleName as string)

Dim styDef As ObjectId = ObjectId.Null

Dim titleStyle As ObjectId = ObjectId.Null

Dim headerStyle As ObjectId = ObjectId.Null

Dim textStyle As ObjectId = ObjectId.Null

Dim titleStyleName As String = "ArialBold"

Dim headerStyleName As String = "Weird"

Dim textStyleName As String = "Arial"

Dim titleSize As Double = 0.2

Dim headerSize as Double = 0.15

Dim textSize As Double = 0.1

Dim textColor As Color = Color.FromColorIndex(ColorMethod.ByAci, CShort(7))

Dim frameColor As Color = Color.FromColorIndex(ColorMethod.ByAci, CShort(4))

Dim backColor As Color = Color.FromColorIndex(ColorMethod.ByAci, CShort(2)

Try

Using dBase As Database = HostApplicationServices.WorkingDatabase

Using trans As Transaction = dBase.TransactionManager.StartTransaction()

'First, get the tablestyle dictionary

Using tbStyleDict As DBDictionary = DirectCast(trans.GetObject(dBase.TableStyleDictionaryId, OpenMode.ForRead, False), DBDictionary)

Dim tableStyle As New TableStyle()

Try

'if it exists, set to it

tableStyle = DirectCast(trans.GetObject(tbStyleDict.GetAt(styleName), OpenMode.ForRead, False), TableStyle)

styDef = tableStyle.ObjectId

'Else create it

Catch

Try

'better make sure these fonts exist before using them!

titleStyle = SetStyle(titleStyleName, "Arial Black", dBase, trans)

headerStyle = SetStyle(headerStyleName, "Algerian", dBase, trans)

textStyle = SetStyle(textStyleName, "Arial", dBase, trans)

tbStyleDict.UpgradeOpen()

tbStyleDict.SetAt(styleName, tableStyle)

tableStyle.Description = styleName

tableStyle.IsHeaderSuppressed = False

tableStyle.IsTitleSuppressed = False


'why back color not working?

' Set background color

tableStyle.SetBackgroundColor(backColor,1) 'data row

tableStyle.SetBackgroundColor(backColor,2) 'title row

tableStyle.SetBackgroundColor(backColor,4) 'header row


' make a heavy "box" around the table

tableStyle.SetGridLineWeight(LineWeight.LineWeight100, 1, 2) 'title row

tableStyle.SetGridLineWeight(LineWeight.LineWeight100, 8, 2) 'title row

tableStyle.SetGridLineWeight(LineWeight.LineWeight100, &H20, 2) 'title row


' Set text height & cell spacing

tableStyle.VerticalCellMargin = 0.1

tableStyle.HorizontalCellMargin = 0.1

tableStyle.SetTextHeight(titleSize, 2) 'title row

tableStyle.SetTextHeight(headerSize, 4) 'header row

tableStyle.SetTextHeight(textSize, 1) 'data row


' Set text style

tableStyle.SetTextStyle(titleStyle, 2) 'title row

tableStyle.SetTextStyle(headerStyle, 4) 'header row

tableStyle.SetTextStyle(textStyle, 1) 'data row


' Set text alignment

tableStyle.SetAlignment(CellAlignment.MiddleCenter, 2) 'title row

tableStyle.SetAlignment(CellAlignment.MiddleCenter, 4) 'header row

tableStyle.SetAlignment(CellAlignment.MiddleLeft, 1) 'data row


' Set text color

tableStyle.SetColor(textColor, 2) 'title row

tableStyle.SetColor(textColor, 4) 'header row

tableStyle.SetColor(textColor, 1) 'data row


' Set frame color

tableStyle.SetGridColor(frameColor, 15, 2) 'title row

tableStyle.SetGridColor(frameColor, &H10, 2) 'title row

tableStyle.SetGridColor(frameColor, &H20, 2) 'title row

tableStyle.SetGridColor(frameColor, 15, 4) 'header row

tableStyle.SetGridColor(frameColor, &H10, 4) 'header row

tableStyle.SetGridColor(frameColor, &H20, 4) 'header row

tableStyle.SetGridColor(frameColor, 15, 1) 'data row

tableStyle.SetGridColor(frameColor, &H10, 1) 'data row

tableStyle.SetGridColor(frameColor, &H20, 1) 'data row


trans.AddNewlyCreatedDBObject(tableStyle, True)

styDef = tableStyle.ObjectId

Catch

main.logger.Error("Could not create table style" & styleName)

End Try

End Try

tableStyle.Dispose()

End Using

trans.Commit()

End Using

End Using

Catch

main.logger.Error("Could access table style dictionary")

End Try

End Sub

Edited by: perry59 on Nov 11, 2009 9:32 PM
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

sorry about the funky formating

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost