You can customize the toolbar in the Viewer control for Windows Forms to implement your own actions.

Here is some example code that demonstrates how to access and change the properties of toolstrip buttons, and shows you where you can customize the processing when you click the custom HQ Print button.

Shows a run-time view of the custom print button showing the tooltip text.

// C#

private ToolStripButton tsbPrint = new System.Windows.Forms.ToolStripButton();

private void frmViewer_Load(object sender, EventArgs e)
{
System.Windows.Forms.ToolStrip toolStrip;
System.Windows.Forms.ToolStripItem orgItem;
System.Windows.Forms.ToolStripButton orgBtn = null;

// Get the image from the standard Print button.
toolStrip = this.viewer1.Toolbar.ToolStrip;
orgItem = toolStrip.Items[2];
if (orgItem is System.Windows.Forms.ToolStripButton)
{
orgBtn = (System.Windows.Forms.ToolStripButton)orgItem;
}

// Delete the standard Print button.
toolStrip.Items.RemoveAt(2);

// Create a custom button to use in place of the standard Print button.
tsbPrint.Text = "HQ Print";
tsbPrint.ToolTipText = "Print to the company headquarters main printer";
tsbPrint.Image = orgBtn.Image;
tsbPrint.Enabled = false;

// Set the event handler. (viewer.LoadCompleted can be set from the designer)
tsbPrint.Click += this.PrintButtonClick;
viewer1.LoadCompleted += this.viewer1_LoadCompleted;

// Add the custom button to the toolbar.
toolStrip.Items.Insert(2, tsbPrint);

// Instantiate the report.
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();

// Load a report definition file.
rpt.Load(new System.IO.FileInfo(@"..\..\PageReport1.rdlx"));
GrapeCity.ActiveReports.Document.PageDocument pageDocument = 
new GrapeCity.ActiveReports.Document.PageDocument(rpt);

// Load the report into the viewer.
viewer1.LoadDocument(pageDocument);
}

// The event to call when the report is loaded into the Viewer.
private void viewer1_LoadCompleted(object sender, EventArgs e)
{
// Enable the custom button.
tsbPrint.Enabled = true;
}

// The event to call when the custom button is clicked.
private void PrintButtonClick(System.Object sender, System.EventArgs e)
{
// Perform print processing.
this.viewer1.Print(true, true, false);
}


' VB.NET

Private tsbPrint As New System.Windows.Forms.ToolStripButton

Private Sub frmViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim toolStrip As System.Windows.Forms.ToolStrip
Dim orgBtn As System.Windows.Forms.ToolStripButton = Nothing
Dim orgItem As System.Windows.Forms.ToolStripItem

' Get the image from the standard Print button.
toolStrip = Me.Viewer1.Toolbar.ToolStrip
orgItem = toolStrip.Items(2)
If TypeOf orgItem Is System.Windows.Forms.ToolStripButton Then
orgBtn = CType(orgItem, ToolStripButton)
End If

' Delete the standard Print button.
toolStrip.Items.RemoveAt(2)

' Create a custom button to use in place of the standard Print button.
tsbPrint.Text = "HQ Print"
tsbPrint.ToolTipText = "Print to the company headquarters main printer"
tsbPrint.Image = orgBtn.Image
tsbPrint.Enabled = False

' Set the event handler (Viewer.LoadCompleted can also be set in the designer)
AddHandler tsbPrint.Click, AddressOf Me.PrintButtonClick
AddHandler Viewer1.LoadCompleted, AddressOf Me.Viewer1_LoadCompleted

' Add the custom button to the toolbar.
toolStrip.Items.Insert(2, tsbPrint)

' Instantiate the report.
Dim rpt As New GrapeCity.ActiveReports.PageReport()

' Load a report definition file.
rpt.Load(New System.IO.FileInfo("..\..\PageReport1.rdlx"))
Dim pageDocument As New GrapeCity.ActiveReports.Document.PageDocument(rpt)

' Load the report into the viewer.
viewer1.LoadDocument(pageDocument)
End Sub

' The event to call when the report loads in the Viewer.
Private Sub Viewer1_LoadCompleted(sender As Object, e As EventArgs)
' Enable the custom button.
tsbPrint.Enabled = True
End Sub

' The event to call when the custom button is clicked.
Private Sub PrintButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)
' Perform print processing.
Me.Viewer1.Print(True, True, False)
End Sub


For more information on how you can customize the Viewer control for Windows Forms and on the index number and name of each toolbar button, check out the following topics in our User Guide.