i want to display water mark text in crystal report whenever i'll preview the report.
for that i created new paragraph object,new field(text box) object then its inserting to crystal report from programatically using C#,
below is the code
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc1 = cryRpt.ReportClientDocument;
ISCRParagraphTextElement paragraphTextElement = new ParagraphTextElementClass();
paragraphTextElement.Text = "TESTING";
paragraphTextElement.Kind = CrParagraphElementKindEnum.crParagraphElementKindText;
ParagraphElements paragraphElements = new ParagraphElementsClass();
paragraphElements.Add(paragraphTextElement);
Paragraph paragraph = new ParagraphClass();
paragraph.Alignment = CrAlignmentEnum.crAlignmentHorizontalCenter;
paragraph.ParagraphElements = paragraphElements;
Paragraphs paragraphs = new ParagraphsClass();
paragraphs.Add(paragraph);
ISCRTextObject textObject = new TextObjectClass();
textObject.Paragraphs = paragraphs;
textObject.FontColor.Font.Bold = true;
textObject.FontColor.Font.Size = 48;
textObject.FontColor.Font.Italic = true;
textObject.FontColor.Color = uint.Parse(ColorTranslator.ToOle(Color.Gray).ToString());
textObject.FontColor.Font.Charset = 30;
textObject.Height = 8000;
textObject.Top = this.Height;
textObject.Left = 5000;
textObject.Width = 1500;
textObject.Format.TextRotationAngle = CrTextRotationAngleEnum.crRotationAngleRotate90;
ReportDefController2 reportDef = rptClientDoc1.ReportDefController;
ReportSectionController reportSectionController = rptClientDoc1.ReportDefController.ReportSectionController;
CrystalDecisions.ReportAppServer.ReportDefModel.Section newsec;
int index = reportDef.ReportDefinition.PageHeaderArea.Sections.Count;
if (index > 0)
{
newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1];
}
else
{
index = 0;
newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index];
}
reportDef.ReportDefinition.PageHeaderArea.Sections.Insert(index, newsec);
CrystalDecisions.ReportAppServer.ReportDefModel.Section sectionToAddTo = reportDef.ReportDefinition.PageHeaderArea.Sections[index];
CrystalDecisions.ReportAppServer.ReportDefModel.SectionFormat newSectionFormat = sectionToAddTo.Format;
newSectionFormat.EnableKeepTogether = false;
newSectionFormat.EnableSuppress = false;
newSectionFormat.EnableUnderlaySection = true;
reportSectionController.SetProperty(sectionToAddTo, CrReportSectionPropertyEnum.crReportSectionPropertyFormat, newSectionFormat);
reportDef.ReportObjectController.Add(textObject, sectionToAddTo, 0);
here issue is new section in PageHeader is copy of previous section in PageHeader,if i change new section in PageHeader properties it also changing previous section in PageHeader ,please help me how to solve this?
This will create new copy of "previous section" and all changes to newsec will not affect to prev. section. As alternative you can also check CopyTo() method.