Showing results for 
Search instead for 
Did you mean: 

Keep Group together in code

Former Member
0 Kudos


We're using Crystal Reports 10 and there's an option in the Group expert to keep the group together.

Is there any way to access this option in code (C#)?

This is not working:

report.GroupHeaderSection1.SectionFormat.EnableKeepTogether = true;

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos


try the following code (groupNo is the number of your GroupHeaderSection1).

ISCRArea area  = reportClientDocument.ReportDefController
GroupAreaFormat groupAreaFormat = (GroupAreaFormat)area.Format.Clone(true);
groupAreaFormat.EnableKeepTogether = true;

Former Member
0 Kudos

I don't seem to have an ISCRArea class. I've searched using the object browser in Visual Studio, but no results.

What is 'reportClientDocument'? What type is it?

Could you explain the code a bit more, please?

0 Kudos

The code is for using the RAS SDK.

I think you need the following dlls:



reportClientDocument is of type ISCDReportClientDocument, which represents the report you are editing or creating with your code.

In the code I copy the group format and make my changes to this copy. After that I apply this changes to the group by calling the SetProperty method.

Hope this helps!

Former Member
0 Kudos

I think I'm missing something. I don't believe we're using RAS.

All reports are created in Visual Studio, so there locally stored in the project.

Can I still use the RAS SDK then?

There seems to be a workaround for it [here|], but I haven't read it completely yet.

0 Kudos

There seems to be a workaround for it here, but I haven't read it completely yet.

Exactly that's the way I use it:

        private CrystalDecisions.CrystalReports.Engine.ReportDocument rdoc;
        private ISCDReportClientDocument rcd;

        rdoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
        rcd = rdoc.ReportClientDocument;

Former Member
0 Kudos

Ok, I tried it but I'm still missing something. I get an error

I'm guessing I have to implement the ISCDReportClientDocument interface in a class and use this class for my code.

Can you point me in the right direction please?

Error 1 The type 'CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument' 
is defined in an assembly that is not referenced. You must add a reference to
assembly 'CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, 
Culture=neutral, PublicKeyToken=692fbea5521e1304'.  Form2.cs 93 13 TestCrystalReports

the code I use

testReport report = new testReport();
ISCDReportClientDocument rcd1 = report.ReportClientDocument;
ISCRArea area = rcd1.ReportDefController.ReportDefinition.get_GroupHeaderArea(0);
GroupAreaFormat group = (GroupAreaFormat)area.Format.Clone(true);
group.EnableKeepGroupTogether = true;

Edited by: Bruno Latte on Mar 24, 2009 8:23 PM

Answers (2)

Answers (2)

0 Kudos

Install the latest Service Packs should fix the issue

Active Contributor
0 Kudos

What is the exact version of CR you are using?

What is the version of .NET you are using?

What is the version of the CR assembly crystaldecicions.crystalreports.engine.dll referenced in your project?

If you use the option in the Group expert of the CR designer, on the same data, do you see the expected result?


Former Member
0 Kudos

If I'm not mistaken we're using CR, well, it's what's installed on my pc anyway.

The target framework is .NET 2.0.

crystaldecicions.crystalreports.engine.dll version 10.5.3700.0

If I go to 'Group Expert' > 'Options' > tab 'Options' and enable 'Keep Group together' , it does what I expect it to do.