cancel
Showing results for 
Search instead for 
Did you mean: 

Location of Change Group Options

Former Member
0 Kudos

Looking in the SDK docs, I cannot for the life of me locate the object that holds the options visible in "Change Group Options".

See attached screenshot.

I do not think it is CrystalDecisions.CrystalReports.Engine.GroupAreaFormat.  That object is what is visible in the Section Expert.

Anyone know where there is a Type enum and getter for these properties?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Steve,

Usually you can use the object browser to find those properties and collections. YOu also did not say which one or all of them you want to use?

See if this is what you want:

CrystalDecisions.CrystalReports.Engine.AreaFormat.EnableNewPageAfter

Or could be this one:

CrystalDecisions.CrystalReports.Engine.SectionFormat.EnableNewPageAfter

And this one:

CrystalDecisions.CrystalReports.Engine.GroupAreaFormat.EnableRepeatGroupHeader

and if you want to change the group name then search for this in the objecty browser:

CrystalDecisions.CrystalReports.Engine.GroupAreaFormat.EnableRepeatGroupHeader

Also, some of these properties can only be modified by using RAS and you would clone the group object and then make changes to it.

Don

Former Member
0 Kudos

I saw those in CrystalDecisions.CrystalReports.Engine and do not think that is it.  In the report in question, note that New Page After N Visible Groups is set.

The object you reference CrystalDecisions.CrystalReports.Engine.GroupAreaFormat I think is represented in teh attached screenshot.

I think I might need RAS, but note I am not trying to change the value, I just want to get the rpt's current value for that property.

The use case I have here is I dump my rpt files to xml for versioning so I can diff when necessary.

Former Member
0 Kudos

Don,  I believe you are correct.  GroupAreaFormat appears to be it.  Just have not successfully been able to query its current state while iterating over ReportDocument.DataDefinition.Groups

Steve

EDIT:

Do you know if it is possible to cast from CrystalDecisions.CrystalReports.Engine.Group to

CrystalDecisions.ReportAppServer.DataDefModel.Group?

Edit2:

Don,  I think this post of yours will help get what I need.  http://scn.sap.com/thread/1246148

0 Kudos

Hi Steve,

I don't have any specific sample code you are looking for but here's how I get the section and area Paper orientation. Mode of the code is to label the output same as what you see in the Designer so you can delete all of that:

private void getSectionPrintOrientation(CrystalDecisions.CrystalReports.Engine.ReportDocument rpt)
{
    string textBox1 = String.Empty;
    string textBox2 = String.Empty;
    string MyObjectType = ReportObjectComboBox1.SelectedItem.ToString();
    btnReportObjects.Text = "";
    int flcnt = 0;
    string SecName = "";
    string SecName1 = "";

    foreach (CrystalDecisions.ReportAppServer.ReportDefModel.Area CrArea in rptClientDoc.ReportDefinition.Areas)
    {
        try
        {
            int RawSectID = 1;
            if (CrArea.Sections.Count > 1)
            {
                //foreach (CrystalDecisions.CrystalReports.Engine.Section crSect in CrArea.Sections) // "DetailSection1"
                foreach (CrystalDecisions.ReportAppServer.ReportDefModel.Section crSect in CrArea.Sections)
                {
                    int sectionCodeArea = (crSect.SectionCode / 1000) % 1000; // Area
                    int sectionCodeSection = (crSect.SectionCode % 1000); // zero based Section
                    int sectionCodeGroup = (((crSect.SectionCode) / 25) % 40); // group section
                    int sectionCodeGroupNo = (((crSect.SectionCode) % 25)); // group area
                    bool isGRoup = false;

                    SecName1 = CrArea.Kind.ToString();
                    SecName1 = SecName1.Substring(17, (SecName1.Length - 17));

                    int crtoChr = 97;
                    char b, c;

                    if (sectionCodeGroup <= 26 && (SecName1 == "GroupFooter" || SecName1 == "GroupHeader"))
                    {
                        isGRoup = true;
                    }
                    else
                    {  // aa and up
                        if (RawSectID <= 26 && !isGRoup) // a to z
                        {
                            btnReportObjects.AppendText(SecName1);
                            c = (char)(RawSectID + crtoChr - 1);
                            btnReportObjects.Text += textBox1 + "  " + c + " : ";
                        }
                        else
                        {
                            btnReportObjects.AppendText(SecName1);
                            if ((char)((RawSectID) % 26) == 0) // test if next "b" and set b back 1 and last letter to z
                            {
                                b = (char)(((((RawSectID) / 26) % 26) - 2) + (crtoChr));
                                c = (char)(122);
                            }
                            else
                            {   // this determines if the name is a or aa.
                                b = (char)((((RawSectID) / 26) % 26) + crtoChr - 1);
                                c = (char)((RawSectID % 26) + crtoChr - 1);
                            }

                            btnReportObjects.Text += textBox1 + " " + b + c + " : " + RawSectID + " - ";
                        }
                    }

                    if (isGRoup)
                    {
                        if (sectionCodeGroup == 0) // && (SecName1 == "GroupFooter" || SecName1 == "GroupHeader")) // only one group area now sections below
                        {
                            btnReportObjects.AppendText(SecName1 + " #" + (sectionCodeGroupNo + 1) + (char)(sectionCodeGroup + crtoChr) + ": " + crSect.Format.PageOrientation.ToString() + "\n");
                            isGRoup = false;
                        }
                        else
                        {
                            btnReportObjects.AppendText(SecName1 + " #" + (sectionCodeGroupNo + 1) + (char)(sectionCodeGroup + crtoChr) + ": " + crSect.Format.PageOrientation.ToString() + "\n");
                            isGRoup = false;
                        }
                    }
                    else
                    {
                        textBox1 += crSect.Format.PageOrientation.ToString() + "\n";
                        isGRoup = false;
                    }
                    btnReportObjects.Text += textBox1;
                    textBox1 = "";
                    btnCount.Text = flcnt.ToString();
                    ++flcnt;
                    RawSectID++;
                }
            }
            else
            {
                SecName = CrArea.Kind.ToString();

                if (SecName == "crAreaSectionKindGroupHeader" || SecName == "crAreaSectionKindGroupFooter")
                {
                    foreach (CrystalDecisions.ReportAppServer.ReportDefModel.Section crSectName in CrArea.Sections)
                    {
                        int sectionCodeArea = (crSectName.SectionCode / 1000) % 1000; // Area
                        int sectionCodeSection = (crSectName.SectionCode % 1000); // zero based Section
                        int sectionCodeGroup = (((crSectName.SectionCode) / 25) % 40); // group section
                        int sectionCodeGroupNo = (((crSectName.SectionCode) % 40)); // group area
                        int crtoChr = 97;

                        if (sectionCodeGroup <= 26)
                        {
                            if (SecName == "crAreaSectionKindGroupFooter")
                                btnReportObjects.AppendText("GroupFooter #" + (sectionCodeGroupNo + 1) + (char)(sectionCodeGroup + crtoChr));
                            else
                                btnReportObjects.AppendText("GroupHeader #" + (sectionCodeGroupNo + 1) + (char)(sectionCodeGroup + crtoChr));
                        }
                        else
                        { // Group higher than -aa
                            char b, c;
                            if ((char)((sectionCodeSection) % 26) == 0) // test if next "b" and set b back 1 and last letter to z
                            {
                                b = (char)(((sectionCodeSection / 26) % 26) + (crtoChr));
                                c = (char)(122);

                                btnReportObjects.AppendText(c + "\n");
                            }
                            else
                            {   // this determines if the name is a or aa.
                                b = (char)((((sectionCodeSection) / 26) % 26) + (crtoChr));
                                c = (char)((sectionCodeSection % 26) + crtoChr - 1);

                                btnReportObjects.AppendText(" " + b + c + "\n");
                            }
                        }
                        //if (CrArea.Name.Substring(0, 11) == crSectName.Name.Substring(0, 11))
                        {
                            btnReportObjects.AppendText(" - ");
                            textBox1 += crSectName.Format.PageOrientation.ToString();
                            btnReportObjects.Text += textBox1;
                            btnReportObjects.AppendText("\n");
                            textBox1 = "";

                            ++flcnt;
                            btnCount.Text = flcnt.ToString();
                            break;
                        }
                    }
                }

                foreach (CrystalDecisions.ReportAppServer.ReportDefModel.Section crSectName in CrArea.Sections)
                {
                    SecName1 = CrArea.Kind.ToString();
                    SecName1 = SecName1.Substring(17, (SecName1.Length - 17));
                    if (SecName1 == "GroupFooter" || SecName1 == "GroupHeader")
                    {
                        //btnReportObjects.AppendText(SecName1 + " #" + (((crSectName.SectionCode) % 40) + 1) + " : ");
                    }
                    else
                    {
                        btnReportObjects.AppendText(SecName1 + " : ");
                        textBox1 += crSectName.Format.PageOrientation.ToString();
                        btnReportObjects.Text += textBox1;
                        btnReportObjects.AppendText("\n");
                        textBox1 = "";

                        ++flcnt;
                        btnCount.Text = flcnt.ToString();
                    }
                    break;
                }
            }
        }
        catch
        {
            btnReportObjects.AppendText("More than one Section in Area. 'End' \n");
        }
    }
}

Should get you onto the Group properties....

Don

0 Kudos

and within the above here's how to get/set the property:

CrystalDecisions.CrystalReports.Engine.Areas areas = rpt.ReportDefinition.Areas;

foreach (CrystalDecisions.CrystalReports.Engine.Area area in areas)

{

    if (area.Kind == AreaSectionKind.GroupHeader)

    {

        CrystalDecisions.CrystalReports.Engine.GroupAreaFormat groupAreaFormat;

        groupAreaFormat = (CrystalDecisions.CrystalReports.Engine.GroupAreaFormat)area.AreaFormat;

        MessageBox.Show(groupAreaFormat.EnableRepeatGroupHeader.ToString());

        //groupAreaFormat.EnableRepeatGroupHeader = true;

    }

}

ido_millet
Active Contributor
0 Kudos

Don, the code above is related to GH/GF Section properties.
How can we retrieve the expression for the Group property of
New Page After N Visible Groups?

0 Kudos

Hi Ido,

I can change the property to turn it on or off but I can't set the formula text... yet... need to do more testing.

Also discovered the Group Expert, Paging tab shows the property enabled:

But if you go through the Report, Group Export it does not show as being enabled:

Only thing I need to check now is who I need to set the text in the formula editor.

Here's what I used:

CrystalDecisions.ReportAppServer.ReportDefModel.Area GHArea = (CrystalDecisions.ReportAppServer.ReportDefModel.Area)rptClientDoc.ReportDefController.ReportDefinition.GroupHeaderArea[0];

groupAreaFormat.EnableNewPageAfter = true;

GHArea.Format.ConditionFormulas[CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeEnableNewPageAfter].Text = "false"; //.ToString();

Don

ido_millet
Active Contributor
0 Kudos

Seems odd that a Group Level property would live under a section property.
In any case, it would be great if you found out how to get/set the formula expression for this property.

0 Kudos

Hi Ido,

So this does work I modified the formula so it affected the out put and then exported to RPT format and it did use the formula to format the group,

Problem I found was it always returned false for all members and no formulae.

Setting them works.

I'll have to get DEV to look into and see if they can make this work....

Thanks again

Don

ido_millet
Active Contributor
0 Kudos

Hi Don,
Glad you managed to confirm the problem. 
Let's hope DEV cooperates...

0 Kudos

Hi Ido,

Use this, must use RAS and clone the original properties:

try

{

    CrystalDecisions.ReportAppServer.ReportDefModel.Area oldGHArea = (CrystalDecisions.ReportAppServer.ReportDefModel.Area)rptClientDoc.ReportDefController.ReportDefinition.get_GroupHeaderArea(0);

    CrystalDecisions.ReportAppServer.ReportDefModel.Area newGHArea = new CrystalDecisions.ReportAppServer.ReportDefModel.Area();

    CrystalDecisions.ReportAppServer.ReportDefModel.GroupAreaFormat group = (CrystalDecisions.ReportAppServer.ReportDefModel.GroupAreaFormat)oldGHArea.Format.Clone(true);

    CrystalDecisions.ReportAppServer.ReportDefModel.ISCRGroupAreaFormat grpAreaFormat = (CrystalDecisions.ReportAppServer.ReportDefModel.ISCRGroupAreaFormat)oldGHArea.Format;

    grpAreaFormat.EnableNewPageAfter = true;

    grpAreaFormat.ConditionFormulas[CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeEnableNewPageAfter].Text = @"if {Orders.Customer ID} < 2 then false"; //.ToString();

    grpAreaFormat.ConditionFormulas[CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeEnableNewPageAfter].Syntax = CrFormulaSyntaxEnum.crFormulaSyntaxCrystal;

    rptClientDoc.ReportDefController.ReportAreaController.SetProperty(oldGHArea, CrReportAreaPropertyEnum.crReportAreaPropertyFormat, grpAreaFormat);

}

catch (Exception ex)

{

    btnReportObjects.Text += "\n" + ex.Message + "\n";

}

This adds the conditional formula to the Group Expert by right clicking on the Group section.


And this will get what exists before the update:

MessageBox.Show(grpAreaFormat.ConditionFormulas[CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeEnableNewPageAfter].Text.ToString());

Don

ido_millet
Active Contributor
0 Kudos

Hi Don,

Your code goes after the GH/GF Section property of 'New Page After'.

But I'm looking for the Group property of 'New Page After N Visible Groups'.


See my message above where I show an image of the dialog that houses that property.  It is not a section dialog, it is a group options dialog.

0 Kudos

Sorry Ido,

I thought you at least would have tried other properties:

//grpAreaFormat.EnableKeepGroupTogether = true;
grpAreaFormat.VisibleGroupNumberPerPage = 1;
//grpAreaFormat.EnableRepeatGroupHeader = true;

grpAreaFormat.ConditionFormulas[CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeGroupNumberPerPage].Text = @"9-8";
grpAreaFormat.ConditionFormulas[CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeGroupNumberPerPage].Syntax = CrFormulaSyntaxEnum.crFormulaSyntaxCrystal;
rptClientDoc.ReportDefController.ReportAreaController.SetProperty(oldGHArea, CrReportAreaPropertyEnum.crReportAreaPropertyFormat, grpAreaFormat);

Should work for you

Don

ido_millet
Active Contributor
0 Kudos

My bad; your code started with Section properties so I gave up too soon.  Thanks!

ido_millet
Active Contributor
0 Kudos

Hi Don,

Were you actually successful in getting (not setting) the expression? 

I tried to use the code below but the Text property returns Nothing even though it was set in the report design to an expression for Group Level 1.

Dim oldGHArea As CrystalDecisions.ReportAppServer.ReportDefModel.Area = DirectCast(rcd.ReportDefController.ReportDefinition.GroupHeaderArea(0), CrystalDecisions.ReportAppServer.ReportDefModel.Area)


Dim grpAreaFormat As CrystalDecisions.ReportAppServer.ReportDefModel.ISCRGroupAreaFormat = DirectCast(oldGHArea.Format, CrystalDecisions.ReportAppServer.ReportDefModel.ISCRGroupAreaFormat)

                            Debug.Print(grpAreaFormat.ConditionFormulas(CrSectionAreaFormatConditionFormulaTypeEnum.crSectionAreaConditionFormulaTypeGroupNumberPerPage).Text)

0 Kudos

Yes:

CrystalDecisions.ReportAppServer.ReportDefModel.Area oldGHArea = (CrystalDecisions.ReportAppServer.ReportDefModel.Area)rptClientDoc.ReportDefController.ReportDefinition.get_GroupHeaderArea(0);

CrystalDecisions.ReportAppServer.ReportDefModel.ISCRGroupAreaFormat grpAreaFormat = (CrystalDecisions.ReportAppServer.ReportDefModel.ISCRGroupAreaFormat)oldGHArea.Format;

textBox1 = "KeepGroupTogether: " + grpAreaFormat.EnableKeepGroupTogether.ToString();

btnReportObjects.Text += textBox1;

btnReportObjects.AppendText("\n");

textBox1 = "VisibleGroupNumberPerPage: " + grpAreaFormat.VisibleGroupNumberPerPage.ToString();

btnReportObjects.Text += textBox1;

btnReportObjects.AppendText("\n");

textBox1 = "RepeatGroupHeader: " + grpAreaFormat.EnableRepeatGroupHeader.ToString();

btnReportObjects.Text += textBox1;

Check the index - GroupHeaderArea(0) possibly yours is not in the first group...

Don

ido_millet
Active Contributor
0 Kudos

My mistake, Don.
Was testing against wrong version of the rpt. Works perfectly fine.

Many Thanks!

Answers (0)