Report Detail Format - Script
Have always used the Essentials report detail format listed below. Now I need it to read one of the fields with deals with status. I need it to change colour to green if the record's status = Signed. How can I alter the script below to print a line green if the record's status = Signed?
bool backColor = true;
public void detail_Format()
{
if (backColor)
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;
}
else
{
rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;
}
backColor=!backColor;
}
public void ActiveReport_PageStart()
{
if (!backColor) backColor = !backColor;
}
Walter
-
Hi Walter,
You can test the fields value, see below.
bool backColor = true;
string greenFieldName = "status";
string greenFieldValue = "Signed";
public void detail_Format()
{
if (backColor)
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;
}
else
{
rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;
}
backColor=!backColor;
//Check for the field value and change the color to Greenif it matches.
string fieldValue = rpt.Fields[greenFieldName].Value as string;
if (fieldValue == greenFieldValue )
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Green;
}
}0 -
Mark,
Thanks for your reply. Although alittle closer, I still get an error on line 25....Error = Identifier expected
bool backColor = true;
string greenFieldName = "site_status";
string greenFieldValue = "Signed";
public void detail_Format()
{
if (backColor)
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;
}
else
{
rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;
}
backColor=!backColor;
//Check for the field value and change the color to Greenif it matches.
string fieldValue = rpt.Fields[site_status].Value as string;
if (fieldValue == greenFieldValue )
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Green;
}
}Walter
0 -
The field name is in the variable 'greenFieldName'.
change this line: string fieldValue = rpt.Fields[site_status].Value as string;
to: string fieldValue = rpt.Fields[greenFieldName ].Value as string;
0 -
Mark,
I still get an error "Exception has been thrown by the target of an invocation"
bool backColor = true;
string greenFieldName = "site_status";
string greenFieldValue = "Signed";
public void detail_Format()
{
if (backColor)
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Silver;
}
else
{
rpt.Sections["detail"].BackColor = System.Drawing.Color.Transparent;
}
backColor=!backColor;
//Check for the field value and change the color to Greenif it matches.
string fieldValue = rpt.Fields[greenFieldName].Value as string;
if (fieldValue == greenFieldValue )
{
rpt.Sections["detail"].BackColor =System.Drawing.Color.Green;
}
}0 -
Walter,
debugging scripting in report designer is a challenge.
Are you able to email your .rpx file to me. I can have a quick look. mhoyland@ssc.nsw.gov.au
0 -
Mark,
Did you receive the email I sent you?
Appreciate your help....Walter
0 -
Walter,
I got your email and replied to it yesterday with some slight changes in the report. Looks like it has not made it to you. I just sent another one to you without attachments to see if gets there. I will update this post with the changes, when I get a chance.
0 -
Hi Mark
I have run into the same issue when trying to toggle the background color based on an input value. I get "Exception has been thrown by the target of an invocation". What kind of changes did you do to the report to make it work?
Martin0 -
Hi All,
I am having the same problem. I cannot figure out how to change the backgroud colors for the text (between yellow/transparent) if the status of my field is unsafe/safe. If anyone has working script and could share it I would very much appreciate it.
Thanks,
Nataliya0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
9 Kommentare