Skip to main content Skip to footer

Implementing AR6 Copy Functionality in AR7

ActiveReports provides a number of ways to view your report output. Besides previewing your report at design time, you can also view the reports you design in the Viewer. This viewer contains a toolbar which provides you with the ability to perform a number of actions including the Copy functionality. In ActiveReports 6 viewer's toolbar the copy functionality is presented by a single Copy button which copies the whole page content to the clipboard. Quite often, our customers ask for this ActiveReports 6 functionality to be implemented in ActiveReports 7. This blog article describes how to export the current page displayed in the viewer to RTF and copy it to the clipboard. In order to add the older copy functionality in AR7 viewer, we need to add our own Copy button to the viewer’s toolbar. This documentation link provides detailed information on customizing the viewer control. Here are the steps involved in the complete implementation:

Adding a Custom Copy button

The first step is to add a custom Copy button to the toolbar. The following code snippet can be used:

ToolStripButton tsbCopy = new ToolStripButton("Copy");  
tsbCopy.Click += new EventHandler(tsbCopy_Click);  

Handling the Copy Button’s Click Event

In the click event of the Copy button added above, we will determine the current page displayed in the viewer. Now, this page can be easily copied to the clipboard using the following code:

private void tsbCopy_Click(object sender, EventArgs e)  
   currentPage = this.viewer1.CurrentPage;  
   sectionDocument.Pages.Add(this.viewer1.Document.Pages[currentPage - 1]);  
   rtfExport.Export(sectionDocument, Application.StartupPath + "\\\RTFExport" + currentPage + ".rtf");  
   sectionDocument.CopyToClipboard(0, 1);  


Sample applications implementing the above functionality can be downloaded in both C# and VB.NET from the following links: Download Sample-C# Download Sample-VB


comments powered by Disqus