ActiveReports 19 .NET Edition
MESCIUS.ActiveReports.Viewer.Win Assembly / GrapeCity.ActiveReports.Viewer.Win Namespace / Viewer Class / Toolbar Property
Example

Toolbar Property (Viewer)
Gets the reference to ToolbarObject of the control.
Syntax
'Declaration
 
Public ReadOnly Property Toolbar As Viewer.ViewerToolbar
 

Property Value

ToolbarObject used for setting tool bar options of view.
Remarks
The toolbar is a key component of the viewer's user interface, offering quick access to common actions such as navigation, zoom, and print. This property allows developers to customize the toolbar to better suit their application's needs.
Example
private ToolStripButton tsbPrint = new System.Windows.Forms.ToolStripButton();

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

            // Get the standard Print button, to get the image.
            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);

            // Add the Custom button, in place of the standard Print button.
            if (orgBtn == null)
            {
                tsbPrint.Text = "Print";
                tsbPrint.ToolTipText = "Print";
            }
            else
            {
                tsbPrint.Text = orgBtn.Text;
                tsbPrint.ToolTipText = orgBtn.ToolTipText;
                tsbPrint.Image = orgBtn.Image;
            }
            tsbPrint.Enabled = false;

            // Set the event handler of the Custom button.
            tsbPrint.Click += this.PrintButtonClick;

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


        //Event to be called when the report is loaded in the Viewer.
        private void viewer1_LoadCompleted(object sender, EventArgs e)
        
        {
            // Enable the Custom button.
            tsbPrint.Enabled = true;
        }

        // Event to be called when the Custom button is clicked.
        private void PrintButtonClick(System.Object sender, System.EventArgs e)
        {
            // Perform the print processing.
            this.viewer1.Print(true, true, false);
        }
    }
}
Private tsbPrint As New System.Windows.Forms.ToolStripButton

Private Sub Form1_Load(...) 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 standard Print button, to get the image.
  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)

  ' Add the Custom button, in place of the standard Print button.
  If orgBtn Is Nothing Then
    tsbPrint.Text = "Print"
    tsbPrint.ToolTipText = "Print"
  Else
    tsbPrint.Text = orgBtn.Text
    tsbPrint.ToolTipText = orgBtn.ToolTipText
    tsbPrint.Image = orgBtn.Image
  End If
  tsbPrint.Enabled = False

  ' Set the event handler of the Custom button.
  AddHandler tsbPrint.Click, AddressOf Me.PrintButtonClick

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

End Sub

' Event to be called when the report is loaded in the Viewer.
Private Sub Viewer1_LoadCompleted(...) Handles Viewer1.LoadCompleted
  'Enable the Custom button.
  tsbPrint.Enabled = True
End Sub

' Event to be called when the Custom button is clicked.
Private Sub PrintButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)
  ' Perform the print processing.
  Me.Viewer1.Print(True, True, False)
End Sub
See Also