I am trying to add content in the detail section of ActiveReport
. But the section height is limited to 2 inches. It is taking only (2/0.2 = )10 items. I want the section to increase its height as the contents increase, so that it can adopt all item. It seems like .CanGrow
is not working. The code I am using is as below.
Dim lObjSecRpt As New GrapeCity.ActiveReports.SectionReport()
Dim lObjLbl As New GrapeCity.ActiveReports.SectionReportModel.Label()
Dim c As Single = 0.2F
Try
lObjSecRpt.Sections.InsertPageHF()
lObjSecRpt.Sections(0).BackColor = Color.WhiteSmoke
lObjSecRpt.Sections(0).Height = 0.0F
lObjSecRpt.Sections.Insert(1, New GrapeCity.ActiveReports.SectionReportModel.Detail())
lObjSecRpt.Sections(1).BackColor = Color.WhiteSmoke
lObjSecRpt.Sections(1).CanGrow = True
For Each dr As DataRow In mObjDtReport.Rows
lObjLbl = New GrapeCity.ActiveReports.SectionReportModel.Label()
lObjLbl.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Left
lObjLbl.Font = New System.Drawing.Font("Arial", 10, FontStyle.Regular)
lObjLbl.Location = New PointF(0.0F, c)
lObjLbl.Height = 0.2F
lObjLbl.Width = 1.0F
lObjLbl.Text = CStr(dr("RptObjNam"))
lObjSecRpt.Sections(1).Controls.Add(lObjLbl)
c += c
Next
Me.rptViewer.LoadDocument(lObjSecRpt)
Ammar,
What you are trying to do in the code is creating sections and adding controls to the sections on the fly. So this is like creating a report layout at runtime. Since you are simply adding controls to the detail section, the format event for the detail section will not fire for each control as it is not bound to any data. Rather you are just adding controls to it. You can check and example of creating reports on the fly here.
If you want that the detail section should grow to show all the added controls, then you will need to increment its height on the basis of the total height of the controls inside it. For example check the sample code below which demonstrates how this can be done. You can simply add this code to the Form_Load event to verify it.
I hope this helps.