This is a migrated thread and some comments may be shown as answers.

Global Report Code

1 Answer 85 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 07 Jan 2009, 11:18 AM
Hi

I have reports which all have the SAME Setup_Report routine
eg. to determine the visibility of report items, groups etc.
(This routine is called in the NEW constructor)

Example:
-------------------------
Public Sub New()
    InitializeComponent()
    Me.Setup_Report()
End Sub
Public Sub Setup_Report()
        If Me.ReportParameters("Group1").Value = eGroup.None Then
            ' No grouping, so clear Groups
            Me.Report.Groups.Clear()
            Me.TextBoxGroupTitle.Visible = False
-------------------------
This works fine, but I want to move the setup routine
to a Public class so that I can keep all the common code in one place

Example.
-------------------------
IN THE REPORT....
-------------------------
Private Shared myFunc As New MyFunctions    ' Global Functions
Public Sub New()
    InitializeComponent()
    myFunc.Setup_Report(Me)
End Sub
-------------------------
IN A GLOBAL.VB ...
-------------------------
Public Class MyFunctions
    Public Sub Setup_Report(ByVal Report As Telerik.Reporting.Report)
            MyReport.ReportParameters.Add("CompanyName", ReportParameterType.String, "Bloggs Limited")
            Dim TextBoxGroupTitle As TextBox = Report.Items("TextBoxGroupTitle")
            TextBoxGroupTitle.Visible = False
-------------------------
In the example above
1) The ReportParameters.Add works
2) The reference to the textbox fails with exception "object reference not set"

Your help greatly appreciated, as this would save massive duplication of setup code....

Kind Regards

Martin

1 Answer, 1 is accepted

Sort by
0
Martin
Top achievements
Rank 1
answered on 07 Jan 2009, 11:51 AM
Hi

PLEASE IGNORE MY PREVIOUS POST!!
I've solved my problem....
I should have been finding report objects using the following:

Dim TextBoxGroupTitle As TextBox = MyReport.Items("pageHeader").Items("TextBoxGroupTitle")
TextBoxGroupTitle.Visible = False

Kind regards

Martin
Tags
General Discussions
Asked by
Martin
Top achievements
Rank 1
Answers by
Martin
Top achievements
Rank 1
Share this question
or