Hi,
I'm trying to add a panel programatically to a report. I have a class that programattically generates a bunch of controls, then puts them in a panel, then returns the panel as an array of ReportItemBase with length of 1.
When i do this it appears to put a page break in after each panel.
I've tried altering the class to return just the controls without the panel parent and it works fine.
This is a problem though, because the reason I'm using a panel to put them inside of, is that I need each set of controls to make sure they are on the same page.
Here's the method
I've got commented out code line around where i've changed things to make it work. I've also tried two methods to add the controls to the panel, one is using the parent property and the other using the items.addrange, both work, but both cause the page break after each panel.
Public
Overrides
Function
RenderControlSet(
Optional
ByRef
parent
As
Telerik.Reporting.Panel =
Nothing
)
As
Telerik.Reporting.ReportItemBase()
'MyBase.RenderControlSet()
Dim
questionDetail
As
DataTable = _questionDetail
Dim
question
As
DataRow = _question
Dim
cbl1
As
ReportsCheckBoxList =
New
ReportsCheckBoxList
Dim
pnl
As
New
Telerik.Reporting.Panel
pnl.Top =
New
Drawing.Unit(StartTop, UnitType.Cm)
pnl.KeepTogether =
True
pnl.StyleName =
"stylePnl"
'pnl.Style.BorderColor=
If
Not
parent
Is
Nothing
Then
pnl.Parent = parent
End
If
Dim
t1
As
New
Telerik.Reporting.TextBox
Dim
TextBoxWidth
As
Drawing.Unit =
New
Drawing.Unit(14 - LeftMargin, UnitType.Cm)
Dim
TextBoxHeight
As
Drawing.Unit =
New
Drawing.Unit(0.6, UnitType.Cm)
t1.Width = TextBoxWidth
t1.Height = TextBoxHeight
t1.Value = question(
"questionText"
).ToString()
t1.Top =
New
Drawing.Unit(0, UnitType.Cm)
't1.Top = New Drawing.Unit(StartTop, UnitType.Cm)
t1.Left =
New
Drawing.Unit(LeftMargin, UnitType.Cm)
t1.StyleName =
"styleQuestion"
'pnl.Items.AddRange(New Telerik.Reporting.ReportItemBase() {t1})
t1.Parent = pnl
' When using the below and comment out the parent line above it works fine
'ReDim Preserve Controls(Controls.Length)
'Controls(Controls.Length - 1) = t1
ResultHeight += 0.6
' CHECK BOX LIST FOR MULTIPLE OPTIONS
cbl1.StartTop = 0.6
'StartTop + 0.6
cbl1.StartTop = StartTop + 0.6
cbl1.LeftMargin = LeftMargin
If
CInt
(question(
"option1"
)) = 0
Then
cbl1.RepeatColumns = 3
Else
cbl1.RepeatColumns =
CInt
(question(
"option1"
))
End
If
cbl1.DataTextField =
"displayText"
cbl1.DataValueField =
"questionDetailId"
cbl1.DataSource = questionDetail
cbl1.Width = TextBoxWidth.Value
Dim
trb()
As
Telerik.Reporting.ReportItemBase
trb = cbl1.Render()
ResultHeight += cbl1.ResultHeight
Dim
x
As
Integer
For
x = 0
To
trb.Length - 1
'pnl.Items.AddRange(New Telerik.Reporting.ReportItemBase() {trb(x)})
trb(x).Parent = pnl
' When using the below and comment out the parent line above it works fine
'ReDim Preserve Controls(Controls.Length)
'Controls(Controls.Length - 1) = trb(x)
Next
pnl.Height =
New
Drawing.Unit(ResultHeight, UnitType.Cm)
ReDim
Preserve
Controls(Controls.Length)
Controls(Controls.Length - 1) = pnl
Return
Controls
End
Function
It's used like this in the VB code else where:
detail.Items.AddRange(c.RenderControlSet())
Where detail is the details section of the report.
I am using verison 4.0.10.423 of the Telerik.Report.dll
Thanks,
Joel