cancel
Showing results for 
Search instead for 
Did you mean: 

Background color problem in embedded field in crystal reports

Former Member
0 Kudos

I have following format in crystal reports

text1

text2

text3

i placed these all 3 fields in text field in crystal reports for proper alignment when they grow vertically,

my problem is that i need to change background color for text2 field,

how can i achieve this

i m using crystal reports for .net 2005

Accepted Solutions (1)

Accepted Solutions (1)

jyothirmayee_s
Active Contributor
0 Kudos

Hi,

if you have Textbox as [@text1@text2@text3], then got to design mode and double click on the Text Box and select the "Text2" >> rightclick>> format field and change the color.

Thanks,

Jothi

JWiseman
Active Contributor
0 Kudos

hi Asif,

as far as i know there is no ability to have different backgrounds in a text object. i.e. the background property is global. i am using cr 14.0.4.738 though so perhaps that's change in a recent patch.

you can change up the font by using rtf interpretation though in this & earlier versions of cr...create a new formula like below, change the stringvars to your field, and then Format the field > Paragraph > Text Interpretation > RTF.  i know it's not the same as having the background change, but it may be a close substitute.

stringvar t1:= {Product.Product Name};
stringvar t2:= {Product.Product Class};
stringvar t3:= {Product_Type.Description};

"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}" +
"{\colortbl ;\red0\green176\blue80;\red255\green255\blue0;\red255\green0\blue0;}" +
"{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1" +

"\cf1\lang9\f0\fs22" + t1 +
// cf1 references the first colour in the color table
// fs is the font size (rtf based)
// f0 is the font type in the font table

"\cf2" + t2 + 
"\cf3" + t3 +

"\cf0\par}"

the rtf tag for background i believe is highlight which doesn't work in my version of cr.

jamie

JWiseman
Active Contributor
0 Kudos

hi Asif,

this was bothering me so i thought of another workaround for you that will emulate a different background for each field in the text object.

using your example of text1, text2, & text3 in your text object already:

1) create a new formula called text1b with syntax like

          numbervar l:= length({text1});

          replicatestring('█',l)

2) create new formulae similar to step 1 for text2 & text3

3) on your report change the font for the existing text object containing text1 to text3 to Courier New or any other fixed width font that you have that has an extended character set (i.e. one that has the 'full block' character in step 1)

4) create a new text object and use the format painter to make the new text object the same font as in step 3

5) drop your new formulae (text1b, text2b, text3b) into the new text object

6) now format the new formulae in the new text object one by one for the colour that you'd like to use as the background

if you see any gaps between the 'full block' character that is acting as the background, it's usually because of your print driver...if you set it to 'no printer' then those should go away.

i hope this helps,

jamie

Answers (1)

Answers (1)

former_member183750
Active Contributor
0 Kudos

In the design view you can do this as follows:

Insert your text object on the report design pane (enter text or what ever)

Right click on the text object

Select "Format Object"

Click on the "Border" tab

Select what ever background color you need

Notice the Conditional formatting button next to the background color drop down. This will let you choose a color on condition as the report runs.

Using your version of CR, this is all you can do. E.g.; there are no exposed APIs that will let you do this at runtime.

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Thanks for your response,

Actually problem is that these all 3 fields are embedded in one text field, and there is no option to change back gourd color for only 1 embedded field, as in my case field 2,please also note, i cannot use multiple sections here, as in parallel i already displaying some data.

former_member183750
Active Contributor
0 Kudos

Ahhh - I get ya. I don't think this is  possible. But, one thing you may want to do, is ask over in the CR Design Space. Some really great people there and they may have suggestions / work-arounds and all that. Start with making the query generic (e.g.; don't mention crystal reports for .net 2005, just say Crystal Reports). A mention of .net makes a lot of people very shy ...

- Ludek