2014-11-10 4 views
0

활성 보고서에 컨트롤을 추가하는 여러 가지 방법이 있다는 것을 알고 있습니다. 내가 좋아하는 다른 웹 페이지를 발견 :활성 보고서의 디자이너에 제어 추가

this.Sections["groupHeader1"].Controls.Add(txt); 

그러나 내가 어떤 컨트롤 디자이너 즉 GrapeCity.ActiveReport.Design.Designer를로드 할 수있는 내 비즈니스의 none입니다. 내 코드에서 이러한 컨트롤을 추가하고 싶습니다. 도와주세요.

답변

1

최종 사용자 디자이너를보고 섹션 기반 보고서 섹션에 컨트롤을 추가하려면 SectionReport 클래스를 사용하여 최종 사용자 디자이너 보고서를 캐스팅하고 그에 따라 섹션에 액세스해야합니다.

다음
private void button1_Click(object sender, EventArgs e) 
    { 
     GrapeCity.ActiveReports.SectionReportModel.TextBox txtBox = new GrapeCity.ActiveReports.SectionReportModel.TextBox(); 
     txtBox.Text = "Hello World!"; 
     txtBox.Location = new Point(1, 1); 
     txtBox.Size = new SizeF(2, 0.5f); 
     ((GrapeCity.ActiveReports.SectionReport)reportdesigner.Report).Sections["Detail"].Controls.Add(txtBox); 
    } 

reportDesigner 디자이너 컨트롤의 이름입니다 예를 들어 버튼 클릭에 보고서의 "세부 정보"섹션에 텍스트 상자를 추가하는 다음 코드를 확인하십시오. 희망이 도움이됩니다.

+0

답변을 주셔서 감사합니다. 답변은 ActiveReports에서 매우 드뭅니다. 나는 문서를 연구함으로써 해결책을 얻었습니다. 내 솔루션도 게시 할 예정입니다. – Ammar

+0

귀하의 답변이 내 해결책보다 타자로 보입니다. – Ammar

0

새로운 SectionReport을 입력하고 Designer.Report을 채택하여이 작업을 수행했습니다. 이제 SectionReport에 컨트롤을 추가하는 것은 Designer.Report에 컨트롤을 추가한다는 것을 의미합니다. 이것은 나를 위해 일했던 것처럼 다음 해결책을 생각한 것입니다.

Dim sr As New GrapeCity.ActiveReports.SectionReport() 

sr = Me.reportdesigner.Report 
''Adding Detail section 
sr.Sections.Insert(1, New GrapeCity.ActiveReports.SectionReportModel.Detail()) 
sr.Sections(1).BackColor = Color.PeachPuff 
sr.Sections(1).Height = 1.5F 

Dim lbl2 As New GrapeCity.ActiveReports.SectionReportModel.Label() 

lbl2.Location = New PointF(0, 0.05F) 
lbl2.Text = "Category ID" 
lbl2.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Center 
lbl2.Font = New System.Drawing.Font("Arial", 10, FontStyle.Bold) 
sr.Sections(1).Controls.Add(lbl2) 

이 답변에 문제가 있으면 알려주십시오.

0

다음은 Form의로드 이벤트에 넣을 수있는 코드입니다.

GrapeCity.ActiveReports.SectionReport sectionReport = new GrapeCity.ActiveReports.SectionReport(); 
    sectionReport.Sections.Add(GrapeCity.ActiveReports.Document.Section.SectionType.Detail, "Body"); 
       GrapeCity.ActiveReports.SectionReportModel.TextBox MyTextBox = new GrapeCity.ActiveReports.SectionReportModel.TextBox(); 
       MyTextBox.Text = "My Runtime Text"; 
       MyTextBox.ShrinkToFit = true; 
       MyTextBox.DataField = "ID"; 
       sectionReport.Sections[0].Controls.Add(MyTextBox);