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