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

ShowPageSetupDialog

4 Answers 166 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Petr
Top achievements
Rank 1
Petr asked on 03 Oct 2016, 07:47 AM

Hello,

I use ReportViewer class and its method ShowPageSetupDialog for the page setup dialog.

When i set some values to out of range (e.g. margins)  in the dialog, then ReportViewer shows object reference error.

Can i prevent this situations, or catch the exception?

Regards,
Tomáš

 

Exception thrown: 'System.NullReferenceException' in Telerik.Reporting.dll

An error has occurred while rendering the report: System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Reporting.Paging.Table.CellAt(Int32 rowIndex, Int32 columnIndex)
   at Telerik.Reporting.Paging.Table.RenderCells(TableRegion region, RectangleRF clip, Double left, Double top, Double reservedLeft, Double reservedTop)
   at Telerik.Reporting.Paging.Table.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.PagingElementBase.AddToPageRecursive(RectangleRF parentClip, Double parentTop, Double parentLeft, Double parentReservedTop, Double parentReservedBottom, Double parentReservedLeft, Double parentReservedRight)
   at Telerik.Reporting.Paging.PagingElementBase.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.PagingElementBase.AddToPageRecursive(RectangleRF parentClip, Double parentTop, Double parentLeft, Double parentReservedTop, Double parentReservedBottom, Double parentReservedLeft, Double parentReservedRight)
   at Telerik.Reporting.Paging.PagingElementBase.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.Group.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.PagingElementBase.AddToPageRecursive(RectangleRF parentClip, Double parentTop, Double parentLeft, Double parentReservedTop, Double parentReservedBottom, Double parentReservedLeft, Double parentReservedRight)
   at Telerik.Reporting.Paging.PagingElementBase.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.Group.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.PagingElementBase.AddToPageRecursive(RectangleRF parentClip, Double parentTop, Double parentLeft, Double parentReservedTop, Double parentReservedBottom, Double parentReservedLeft, Double parentReservedRight)
   at Telerik.Reporting.Paging.PagingElementBase.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.Group.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.PagingElementBase.AddToPageRecursive(RectangleRF parentClip, Double parentTop, Double parentLeft, Double parentReservedTop, Double parentReservedBottom, Double parentReservedLeft, Double parentReservedRight)
   at Telerik.Reporting.Paging.PagingElementBase.AddChildrenToPage(RectangleRF clip)
   at Telerik.Reporting.Paging.PagingElementBase.AddToPageRecursive(RectangleRF parentClip, Double parentTop, Double parentLeft, Double parentReservedTop, Double parentReservedBottom, Double parentReservedLeft, Double parentReservedRight)
   at Telerik.Reporting.Paging.PageCompositionBase.CollectElementsAndDataForPage()
   at Telerik.Reporting.Paging.PageCompositionBase.OutputPage()
   at Telerik.Reporting.Paging.PageCompositionBase.CreatePages()
   at Telerik.Reporting.Paging.PagerBase.Telerik.Reporting.Paging.IPager.CreatePages(IPageHandler handler, Report report)
   at Telerik.Reporting.BaseRendering.RenderingExtensionBase.Render(Report report, Hashtable renderingContext, Hashtable deviceInfo, CreateStream createStreamCallback, EvaluateHeaderFooterExpressions evalHeaderFooterCallback)

4 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 05 Oct 2016, 04:21 PM
Hello Tomas,

If you use the 'Page Setup' button of the WPF|WinForms ReportViewer, there is included validation. Please note that this is an external dialog used by viewers to provide options for specifying the physical pages.

Please elaborate which Telerik Reporting version is used, and how the exceeding value for the margin is entered in the report's PageSettings.


On a side note, errors on processing a report can be caught in the report's Error event, and in the viewer's Error event.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Petr
Top achievements
Rank 1
answered on 06 Oct 2016, 09:01 AM

I have WPF app and i use the latest Telerik Reporting version 10.2.16.914. I edited template file Telerik.ReportViewer.Wpf in this app, hid default toolbar and created own. For show the Page Setup i placed the standard WPF button to the own toolbar. After click this button, i call ShowPageSetupDialog method on the report viewer object.

When i set some big value e.g. 600 to margin, the validation dialog is shown. But when i set e.g. 50 to margin i give the object reference error. The same report in the Telerik Report Designer and its Page Setup dialog behaves correctly.

XAML

xmlns:telerikReporting="clr-namespace:Telerik.Reporting;assembly=Telerik.Reporting"

 <tr:ReportViewer Grid.Row="1" x:Name="ReportViewer1" ZoomPercent="{Binding SelectedZoomItem.Value,Mode=TwoWay}"  HorizontalAlignment="Stretch" ReportSource="{Binding ReportSource, Mode=TwoWay}" ViewMode="PrintPreview" cal:Message.Attach="[Event Loaded] = [Action ReportViewer_Loaded($source)]">
                </tr:ReportViewer>

CODE

 public void ReportViewer_Loaded(object sender)
        {
            rv = (ReportViewer) sender;         
            rv.UpdateUI += Rv_UpdateUI;        

            rv.Error += Rv_Error;

        }

public void PrintSettings()
        {                                            
            rv.ShowPageSetupDialog();
            rv.RefreshReport();            
        }

0
Stef
Telerik team
answered on 10 Oct 2016, 02:47 PM
Hi Tomas,

The dialog that can be raised through the viewer has validation, not allowing margins to be greater than the paper size.

Please open a support ticket and send us a demo project that reproduces the problem. Test also if the problem occurs with any report or only with such having specific layout or settings in code.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Petr
Top achievements
Rank 1
answered on 19 Oct 2016, 10:35 AM

Hi Stef,

I upgraded Telerik Reporting to R3 2016 and add configSection to app configuration file.

Now it is all fine.

Thank you for help.

Regards,

Tomas

Tags
General Discussions
Asked by
Petr
Top achievements
Rank 1
Answers by
Stef
Telerik team
Petr
Top achievements
Rank 1
Share this question
or