Change Landscape Orientation in Code

I am using Fast-Report.NET 1.5.3 with Visual Basic Express 2010.

I am creating a custom preview form using the FR PreviewControl and a custom page setup dialog. After the report is shown in my custom preview form, I am attempting to change its landscape orientation with code similar to the following:

Private Sub ChangeOrientation(ByVal LandscapeOrientation As Boolean) 'LandscapeOrientation is a boolean passed from my custom page setup dialog
Dim pg As FastReport.ReportPage = MyReport.Pages(0)
pg.Landscape = LandscapeOrientation
MyReport.Show()
End Sub

When pg.Landscape is False and my code changes it to True, the report changes to landscape in the PreviewControl as expected. However, when pg.Landscape is True and I change it to False, the report does not change to portrait. I checked the Landscape property on the report and confirmed that it was reset to False. It seems that i need something else to force the display to refresh.

When i use the built-in page setup dialog, the report always toggles from Landscape to Portrait, as expected.

Am I missing something?

Thanks,
Paul

Comments

  • edited March 2011
    I use following code and it works correctly:
    private void ChangeOrientation(bool landscapeOrientation)
    {
        ReportPage page = report.FindObject("Page1") as ReportPage;
        page.Landscape = landscapeOrientation;
        report.Show();
    }
    
    And I recommend you to update FastReport .NET.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.