0

보고서를 미리 볼 때마다 크리스탈 보고서에 워터 마크 텍스트를 표시하려고합니다. 그것을위한 내가 객체가, 프로그램 사용 C 번호로부터 결정 보고서의 삽입 아래
코드 뉴 단락 객체 새로운 필드 (텍스트 박스)를 생성
C# 크리스탈 리포트의 페이지 헤더 섹션 프로그래밍 방식으로 작성

CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rptClientDoc1 = cryRpt.ReportClientDocument; 내가 그것을 또한 PageHeader에 이전 섹션을 변경 PageHeader 속성에서 새 섹션을 변경하는 경우

 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); 


여기에 문제가 PageHeader
에서 새로운 섹션은이 PageHeader이전 섹션의 복사본입니다, 도와주세요 어떻게 해결할 수 있을까요?

답변

1
int index = reportDef.ReportDefinition.PageHeaderArea.Sections.Count; 
    if (index > 0) 
    {    
     newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index - 1].Clone(); 
    } 
    else 
    { 
     index = 0; 
     newsec = reportDef.ReportDefinition.PageHeaderArea.Sections[index].Clone(); 
    } 

이렇게하면 "이전 섹션"의 새 복사본이 만들어지고 newsec의 모든 변경 사항은 이전에 영향을주지 않습니다. 섹션. 대안으로 CopyTo() 메소드를 확인할 수도 있습니다.