How to Programmatically Determine Current Page Being Designed
I am working with a DesignerControl control and want to programatically make some change to the report design of the page the user is viewing/editing in the designer control.
I can make the changes to a hard-coded page, like the first page in the report, just fine. But I want to determine which page is the currently edited page and make the changes to that page. How do I do that?
I could not find a suitable property on the designer control. I then tried looking at the report itself and I found.
Report.Pages.OfType<ReportPage>().FirstOrDefault(x => x.IsSelected);
This works sometimes, but not always. I don't why but sometimes there are no pages that are IsSelected==true. I can't find any documentation for IsSelected so maybe its not appropriate. I just took a stab at it.
How can I determine which report page is currently being viewed in the designer?
thanks
Comments
Hello!
You can determine the current report page being edited in the WinForms Designer directly from the DesignerControl.ActiveReport / Designer.ActiveReportTab property.
In the plug-in or host form, obtain an instance of DesignerControl (or RibbonDesignerControl).
The active report tab (ActiveReportTab) contains the active page editor (ActivePageDesigner), from which you can read the ActiveReport property (current page, ReportPage) or SelectedReportComponents.