Checkbox in a Crystal Report

2019-08-28 18:53发布

问题:

What is the best way to display a checkbox in a Crystal Report?

Example: My report has a box for "Male" and "Female", and one should be checked.

My current workaround is to draw a small graphical square, and line it up with a formula which goes like this:

if {table.gender} = "M" then "X" else "  "

This is a poor solution, because changing the font misaligns my "X" and the box around it, and it is absurdly tedious to squint at the screen and get a pixel-perfect alignment for every box (there are dozens).

Does anyone have a better solution? I've thought about using the old-style terminal characters, but I'm not sure if they display properly in Crystal.

Edit: I'm using Crystal XI.

回答1:

Try a pair of images with a conditional formula for visibility



回答2:

If {Table.Field} = True Then

'Display the checkbox of your choice here

Formula = Chr(254)

Else

'Display empty checkbox

Formula = Chr(168)

End If


回答3:

An alternative to images could be to use the Wingdings font; Characters 0xFE (checked) and 0xA8 (unchecked).



回答4:

I need to mention here which is font need's to select here "Wingdings"

If {Table.Field} = True Then

'Display the checkbox of your choice here

Formula = Chr(254)

Else

'Display empty checkbox

Formula = Chr(168)

End If


回答5:

I never use a box...I always use a textfield object with a full border, centered alignment and bold. Type an X inside to size it right. Erase the "X". Copy/paste as many as you need.

Then I create all the formulas that return either "X" or " " (the space is important, otherwise border will not display on the text object). Then simply plop the formula fields into the right boxes.

Also, if you want to align these bordered text objects you need to remove the border before aligning. That bug really annoys me!



回答6:

2 pictures
1 - Empty box
2 - Checked box

Display the right picture with a formula



回答7:

  1. Create a Formula Field and use the following formula

if {Your Field} = true then Chr(254) else Chr(168)

  1. Add the Formula field to the report where you want the checkbox to appear.

  2. Now change the font of the formula field to Wingdings.