0
votes

problem definition:
having data with symbolic colors (i.e each teacher is noted with a color)
in DataGridView displaying a simple SELECT query result, I managed to color each row with its teacher's color
using visual studio 2012 and crystal report for VS 13.0.5

public void setColor() {
        int index = this.Dgv.Columns["color"].Index;
        foreach (DataGridViewRow row in this.Dgv.Rows)
        {
            System.Drawing.ColorConverter cc = new System.Drawing.ColorConverter();
            System.Drawing.Color c = (System.Drawing.Color)cc.ConvertFromString(row.Cells[index].Value.ToString());
            row.DefaultCellStyle.BackColor = c;
        }
        this.Dgv.ClearSelection();
    }

I'd like to get a similarly styled report in crystal report but I'm having problems with color manipulation, the far I could get was alternating row color as many articles online help me through.
crystal report color issues I've found while searching were solved by applying the logic in a formula but in my case the colors are within the bound dataset (color values like "WHITE", "#FF0092" etc)

I thought of changing how the color is stored to (rr,gg,bb) to make use of the Color function in crystal report, would the function accept the string instead of 3 parameters?

to wrap my question up:
- is it possible to achieve the same level of color-control in crystal reports as in C#?
- is it possible to string-manipulate the (rr,gg,bb) string to extract the 3 needed parameters?

any pointers are appreciated
please include explanation since I'm a CR newbie
thank you

1
You have to create formula, parsing your dataset color field and returning CR compatible color.Arvo

1 Answers

0
votes

Not certain I understand the 2nd part. You can definitely achieve total color control.

Try a formula called Color. Define it as: if {Teacher}='teacher1' then color(1,2,3) else if ...

for each of the teachers.

A CASE statement will work as well.

Then in the Section Expert for the desired section select color, then 'more' to get to the formula expert. Simply insert the name of the formula you just created - @color