Hello Group,
I am working to make a 2dTable to be able to change font color based on exceeding limits values.
Background:
Am using DIAdem 2019 SP1, Windows 10 pro 64.
Was working with example from forum by Winner, This works partly, in that it will color the first column but not the subsequent columns. (in my case the 2Dtable is 7 columns wide!)
Code used for user Commands.
Sub MyOnDrawingCell_1(Context, Cell)
'If (Context.Table.Name = "2DTable") Then
If (Cell.Value > 0.0) Then
Cell.Font.Color.SetPredefinedColor(2)
else
Cell.Font.Color.SetPredefinedColor(5)
End If
'End If
End Sub
Sub MyOnDrawingCell_2(Context, Cell)
'If (Context.Table.Name = "2DTable") Then
If (Cell.Value > 0.0) Then
Cell.Font.Color.SetPredefinedColor(2)
else
Cell.Font.Color.SetPredefinedColor(5)
End If
'End If
End Sub
Code used to build the Table
'-------------------------------------------------------------------------------
'-- VBS script file
'-- Created on 04/15/2020 08:57:50
'-- Author:
'-- Comment:
'-------------------------------------------------------------------------------
Option Explicit 'Forces the explicit declaration of all the variables in a script.
Dim oMy2DTable, oMyPosition, oMyColumn1, oMyColumn2
Call Report.NewLayout()
Set oMy2DTable = Report.ActiveSheet.Objects.Add(eReportObject2DTable,"My2DTable")
Set oMyPosition = oMy2DTable.Position.ByBorder
oMyPosition.Top = 30
oMyPosition.Bottom = 20
oMyPosition.Left = 20
oMyPosition.Right = 30
Set oMyColumn1 = oMy2DTable.Columns.Add(e2DTableColumnChannel)
oMyColumn1.Channel.Reference = "[1]/[1]"
Set oMyColumn2 = oMy2DTable.Columns.Add(e2DTableColumnChannel)
oMyColumn2.Channel.Reference = "[1]/[2]"
oMy2DTable.Settings.IndexSettings.IndexMode = e2DTableIndexModeAutomaticallyIncreasing
oMyColumn1.Settings.OnDrawingCell = "MyOnDrawingCell_1"
oMyColumn2.Settings.OnDrawingCell = "MyOnDrawingCell_2"
Questions List:
1) When I run the script to make the table, the result is that I can get column 1 to correctly color the fonts. But it will not in Column 2. Do not understand why it is not working.
2) When I tried to set the event code from the GUI
![Pesmith8_0-1586960137076.png Pesmith8_0-1586960137076.png]()
Unsure what to put into this block. Seems that if script set this value, then it works partially, but if set in gui have yet to get it to work.
If anyone can help with a working table building code or TDR and usercommand function that works, that would be very appreciated.
Paul