How to change the text color in report according to the condition?
mohanaraj
600001
Dear all,
I want to change the color of the text in the report by condition.
eg:
Extension Call-Description
315 Incoming
316 Incoming
317 Outgoing
318 Incoming
the above data is displayed in a report. In this report i want to change the text color for the Incoming records and another color for outgoing.
eg incoming records - blue color.
Outgoing records - Red color.
Please advice how to change the color of text according to the conditions.
thanks in advance.
I want to change the color of the text in the report by condition.
eg:
Extension Call-Description
315 Incoming
316 Incoming
317 Outgoing
318 Incoming
the above data is displayed in a report. In this report i want to change the text color for the Incoming records and another color for outgoing.
eg incoming records - blue color.
Outgoing records - Red color.
Please advice how to change the color of text according to the conditions.
thanks in advance.
Comments
Use conditional highlight:
http://fast-report.com/documentation/UserM...cthighlight.htm
Thanks for the reply.
How i do the same by program?
Because the color of the font can be described dynamicaly from the program.
thaks in advance.
The TextObject has Highlight property which is the collection of highlight conditions. Please refer to the Class Reference.
How to compare the string value in this.
Error Occurs throw as "The name 'Outgoing' does not exist in the current context"
My code is
<TextObject Name="Text5" Width="73.3" Height="18.9" Text="[dtAllCallDetailReport.Date]">
<Highlight>
<Condition Expression="[dtAllCallDetailReport.Call_Description] == Outgoing"/>
</Highlight>
</TextObject>
please advice.
Don't you forget to add quotes?
[dtAllCallDetailReport.Call_Description] == "Outgoing"
In my report i change the color of the text according to the user changed colors.
eg - For Report
Extension - Call_Type
315
Incoming
316
13Calls
317
Outgoing
318
IDD
I change the color in the report as per the data submitted by users this data is load from Database and registered as follows
Call_Type - Color
Incoming - Green
13Call
Blue
Outgoing--- Red
IDD
Yellow
This above details are load from database.
Now i want to change the color according to the data submitted by user.
Note : In calltype_Color table Call type is dynamic we can't hard code the call_Type in conditions.
Please help me how to use the conditional highlight in this case [img]style_emoticons/<#EMO_DIR#>/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /> Thanks in advance.[/img]
You can't use highlight in this case.
- set up the relation between two tables (main table and color table). Join them by Call_Type column;
- write the script (TextObject.BeforePrint). Something like this:
string colorName = (String)Report.GetColumnValue("MainTable.ColorTable.Color");
Text1.TextColor = (Color)(new ColorConverter().ConvertFromInvariantString(colorName));
Dear Alex,
I tried out , by create relation between the tables but in the result all data shown in single color that color is the first record of the color table. I can't found where it goes wrong.
I attached my sample application in this application click the Email Icon and view the pdf file in "createdreports" folder.
Please advise where i was wrong.
Thanks in advance.
There are two errors in your report:
1) The relation is incorrect, you have to switch Parent and Child tables (parent = dtColorDetail, child = dtAllCallDetailReport).
2) Error in the script:
Thanks its work fine thank you.
But in the child table (dtAllCallDetail) table some time there may be possible to bind the empty data and the parent table (dtcolor) having data in this situation the relation fails the application with error "Cannot determine conversion method. "
how i can overcome this issue?
Before the Before_Print Event i have to check the row count of the child table ?
Thanks in advance..
if (String.IsNullOrEmpty(colorName))
Text1.TextColor = Color.Black
else
...
Thanks, But i found that the error occurs in this line "[SecondsToHHmmss([TotalDuration]/[Totalcalls])]"
I use this function for calculate the total duration in HH:MM:SS in this function [TotalDuration] and [Totalcalls] are totals.
In this, while the dtAllcallDetail's data table have the field Tduration this column is sum in [TotalDuration] and in the [TotalCalls] i use count.
My procedure returns an empty dataset to dtAllcallDetail table at the same time the dtColortable have all records the [TotalDuration] total sum the duration of all the records ie empty so it have empty value. But the count [Totalcalls] return 0 by calculation, so now calculation comes to Emptyvalue / 0 in this case error occur how can i overcome this.
Thanks in advance.
You can use IIF function to check for 0. Something like
[IIF([Totalcalls] == 0, "", SecondsToHHmmss([TotalDuration]/[Totalcalls]))]
-or-
[[Totalcalls] == 0 ? "" : SecondsToHHmmss([TotalDuration]/[Totalcalls])]
Hello,
I use the following code TotalIncText.Text = "[[Totalcalls] == 0 ? '' : SecondsToHHmmss([TotalDuration]/[Totalcalls])]";
it throw an error as "Empty character literal" how can i implement this. to the text property of text object.