DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional formatting for textlist?

Solved!
Go to solution

Hello all,

 

I am new to DIAdem and I am trying to format the already existing report templete which contains the table in which rows are defined usind the textlist. I am trying to vary the font color as per the values in every column.

 

I tried to write the script and it functioned well when a column of a table is a channel but for the textlist  whose columns are made of different channel values, I am not able to find anything. Is it even possible to achive while using textlist, if yes then please guide me through.

 

Regards

0 Kudos
Message 1 of 13
(5,115 Views)
Solution
Accepted by topic author Sarry

Hi Sarry,

 

You need to create and register a user command that will be executed when drawing any cell in the table.

User commands can be registered like this:

 

'register user command for the first column in the first table of the first sheet
Report.Sheets(1).Objects(1).Columns(1).Settings.OnDrawingCell = "TableDrawingCell"

In my example there must be a procedure called "TableDrawingCell" in another vbs file that is registered under Settings»Options»Extensions»User Commands.

Each time the "OnDrawingCell" Event is called, you can access cell indices with Context.Col and Context.Row to decide if you want to change color for the current cell.

If you want to change font colors (e.g. to red) you can use the following code:

Cell.Font.Color.SetRGBColor(RGB(255, 0, 0))

Attached you can find a simple example.

 

Regards Christian

Christian
CLA, CTA, CLED
0 Kudos
Message 2 of 13
(5,065 Views)

Hi Sarry,

 

It looks like you've uncovered a bug in DIAdem 2015.  R&D looked into this and discovered that only the first column of a table with "Text List"  columns can be conditionally formatted with a UserCommand.

 

Thanks for pointing that out,

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 3 of 13
(5,062 Views)

Hi,

 

Thats good. It would be great if you can solve such an issue. Please do update with the status regarding the same.

 

Regards

0 Kudos
Message 4 of 13
(5,049 Views)

Hi Brad,

 

Thanks for the information.

In my example it seemed to work or did I misunderstand the issue?

 

Regards

Christian

Christian
CLA, CTA, CLED
0 Kudos
Message 5 of 13
(5,042 Views)

Hi Christian,

 

Actually, your example does work for me in both DIAdem 2014 and DIAdem 2015.  Now I'm not sure what R&D is referring to.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 6 of 13
(5,030 Views)

Hi Christian,

 

Thanks a lot for the solution. By looking at your example it looks like it is possible with the text list as well.

 

Regards

0 Kudos
Message 7 of 13
(5,016 Views)

Hi CHristian,

 

In the example you have provided it is using the color info provided by the user in TagTemporary but I want to decide the color based on the value the cell is having. How can I do that. It would be great if you can guide.

 

Regards

0 Kudos
Message 8 of 13
(5,010 Views)

Hi Sarry,

 

you can use Cell.Value to access each cells value.

In my example just make to following changes:

 

 

if Cell.Value = "Insert conditional value here" then
...
   Cell.Font.Color.SetRGBColor(RGB(255, 0, 0))    
end if

Here you can find documentation about that (see properties at the end):

2DTableDrawingCellContext

2DTableDrawingCell

 

Best regards

Christian

 

Christian
CLA, CTA, CLED
0 Kudos
Message 9 of 13
(5,004 Views)

Hi,

 

Thanks a lot and it looks like it is working except one thing. It seems like it is looking at the very first position of the value as you can see in piture. I asked to make it red if value is greater then 2 else make it green. So its making all values starting with 1 green even though the are greater than 2. Can you please guide further? Unbenannt.PNG

0 Kudos
Message 10 of 13
(4,988 Views)