Customization of ReportViewer and ReportDesigner Behavior Using Actions

Dmitry Zhukov

It is possible to configure ReportViewer’s and ReportDesigner’s behavior by using Actions.

In order to override an action you need to write the Action.Executing event handler and set the ‘true’ value for the e.Handled flag. Then you need to implement the necessary behavior.

reportDesigner.Actions["ActionName"].Executing += new PerpetuumSoft.Reporting.Windows.Forms.Action.ExecutingEventHandler(ActionName_Executing);

void ActionName_Executing(object sender, PerpetuumSoft.Reporting.Windows.Forms.ExecutingEventArgs e)
{
e.Handled = true;

}



If you need to handle the action after it is executed, you need to write the Action.Execute event handler and set the ‘true’ value for the e.Handled flag. Then you need to implement the necessary behavior.

reportDesigner.Actions["ActionName"].Execute += new EventHandler(ActionName_Execute);

void ActionName _Execute(object sender, EventArgs e)
{

}


In order to execute Action you need to use the following code:

reportDesigner.Actions["ActionName"].ExecuteAction()


All possible Actions for the ReportDesigner:
“SelectMode” – switches to object selection mode
“PanMode” – switches to pan mode that allows a user to scroll content with mouse.
“ZoomInMode” – switches to zoom in scale mode
“ZoomOutMode” – switches to zoom out scale mode
“WindowZoomMode” – switches to scaling of selected area mode
“DynamicZoomMode” – switches to dynamic scaling mode
“CustomZoom” – opens the window that allows a user to set custom scale
“Zoom25″ – sets scale to 25%
“Zoom50″ – sets scale to 50%
“Zoom75″ – sets scale to 75%
“Zoom100″ – sets scale to 100%
“Zoom125″ – sets scale to 125%
“Zoom150″ – sets scale to 150%
“Zoom200″ – sets scale to 200%
“Zoom300″ – sets scale to 300%
“Zoom500″ – sets scale to 500%
“DocumentProperties” – shows properties of a document
“PageProperties” – shows properties of the selected page
“Open” – shows the ‘Open Document’ dialog
“Save” – saves changes to a document
“SaveAs” – shows the ‘Save Document’ dialog
“Undo” – removes pending changes from a workarea.
“Redo” – reverses the undo or advances the buffer to a more current state.
“NewDocument” – creates a new document
“AddPage” – adds a page to a document
“DeletePage” – deletes a page from a document
“CopyPage” – copies a page in a document
“DeleteObjects” – deletes the selected elements
“CutObjects” – cuts the selected elements
“CopyObjects” – copies the selected elements to the clipboard
“PasteObjects” – pastes elements to the clipboard
“SendToBack” – sends the element to the back of the all the elements of the container
“BringToFront” – brings the element to the front of all the elements of the container
“MoveBack” – moves the position of the element to one level back
“MoveForward”– moves the position of the element to one level forward
“ShowGrid” – shows grid on the page
“SnapToGrid” – snaps an element sizes and position to the grid
“LayoutBands” – automatically aligns the sections vertically
“DataSources” – activates the DataSourceTree element
“Preview” – preview of the generated report
“CheckScript” – checks the scripts correctness in the report template
“ShowObjectBounds” – shows bounds of the elements
“ShowAlignForm” – shows alignment form for selected elements
“ShowRulers” –shows/hides rulers
“WholePage” – shows the whole page
“PageWidth” –scales page by width
“ActualSize” – scales to 100%
“About” – opens the window with information about the product
“SelectLanguage” – opens the window that allows a user to select localization language

All the possible Actions for the ReportViewer:
“Print” – prints a document
“Load” – opens a document
“Save” – saves a document
“Export” – exports a document
“Pan” – switches to pan mode that allows a user to scroll content with mouse.
“DynamicZoom” – dynamical scaling
“ZoomIn” – switches to zoom in scale mode
“ZoomOut” – switches to zoom out scale mode
“ZoomRectangle” switches to scaling of the selected area mode
“CustomZoom” – opens the window that allows user to set custom scale
“Zoom25″ – sets scale to 25%
“Zoom50″ – sets scale to 50%
“Zoom75″ – sets scale to 75%
“Zoom100″ – sets scale to 100%
“Zoom125″ – sets scale to 125%
“Zoom150″ – sets scale to 150%
“Zoom200″ – sets scale to 200%
“Zoom300″ – sets scale to 300%
“Zoom500″ – sets scale to 500%
“Content” – opens bookmark tree in a document
“Find” – searches for text within a document
“FindNext” – continues a search that was begun with the Find Action.
“WholePage” – shows the whole page
“PageWidth” – scales page by width
“ActualSize” – scales to 100%
“Forward” – moved forward through the navigation history
“Backwards” – moves backward through the navigation history
“FirstPage” – goes to the first page of a report
“PrevPage” – goes to the previous page of a report
“NextPage” – goes to the next page of a report
“LastPage” – goes to the last page of a report
“GotoPage” – opens the window that allows a user to move to the specified page
“EditReport” – opens a document editor
“RefreshReport” – causes the current report in the Report Viewer to be processed and rendered
“SinglePage” – displays a report in per page view mode
“ContinuedPage” – displays a report in continuous view mode
“About” – opens the window with information about the product

You may find the example within our Samples Center: Reports -> Using -> Custom Viewer.

In order to create your own designer form, you may use some of the following components:
ReportDesigner – component of the template editor
DesignerErrorList – component for displaying errors in scripts of the template
DesignerPropertyGrid – component for displaying properties of the selected objects
DesignerDataSourcesTree – component for displaying connected data sources
DesignerDocumentTree – component for displaying document structure as the tree
DesignerStatusBar – status bar for the designer

Please see the example of fully implemented form of the designer…

March 24th, 2011

Leave a Comment