ActiveReports 15 .NET Edition
GrapeCity.ActiveReports.Viewer.Win Assembly / GrapeCity.ActiveReports.Viewer.Win Namespace / Viewer.ViewerToolbar Class / MainBar Property
Example

In This Topic
    MainBar Property
    In This Topic
    The main tool strip in the Windows Forms Viewer control.
    Syntax
    'Declaration
     
    Public ReadOnly Property MainBar As ToolStrip
    public ToolStrip MainBar {get;}
    Remarks

    Items on this toolstrip and their index numbers:

    • 0 Toggle sidebar
    • 1 Separator
    • 2 Print
    • 3 Galley mode
    • 4 Separator
    • 5 Copy
    • 6 Find
    • 7 Separator
    • 8 Zoom out
    • 9 Current zoom
    • 10 Zoom in
    • 11 Separator
    • 12 Fit width
    • 13 Fit page
    • 14 Separator
    • 15 Single page view
    • 16 Continuous view
    • 17 Multipage view
    • 18 Refresh
    • 19 Cancel

    You can access these items by index with the Insert and RemoveAt methods. Other methods are described in the System.Windows.Forms.ToolStripItemCollection documentation on MSDN.

    Example
    This code removes the print button and replaces it with one that calls a custom print dialog.
    private void Form1_Load(object sender, EventArgs e)
          {
              //Remove the print button. 
              viewer1.Toolbar.MainBar.Items.RemoveAt(2);
              //Remove the extra separator.
              viewer1.Toolbar.MainBar.Items.RemoveAt(1);
              //Add a new button to the end of the main bar with the caption "Print."
              ToolStripButton tsbPrint = new ToolStripButton("Print");
              viewer1.Toolbar.MainBar.Items.Add(tsbPrint);
              //Create a click event handler for the button.
              tsbPrint.Click += new EventHandler(tsbPrint_Click);
    
              SectionReport1 rpt = new SectionReport1();
              viewer1.LoadDocument(rpt);
    
          }
    
          //Call the custom dialog from the new button's click event.
          void tsbPrint_Click(object sender, EventArgs e)
          {
              this.CustomPrint();
          }
    
    //Call the custom print dialog.
          private void CustomPrint()
          {
              frmPrintDlg _printForm = new frmPrintDlg();
              _printForm.ShowDialog(this);
          }
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim rpt As New SectionReport1
        Viewer1.LoadDocument(rpt)
    
        'Remove the print button. 
        Viewer1.Toolbar.MainBar.Items.RemoveAt(2)
        'Remove the extra separator.
        Viewer1.Toolbar.MainBar.Items.RemoveAt(1)
        'Add a new button to the end of the main bar with the caption "Print."
        Dim tsbPrint As New ToolStripButton("Print")
        Viewer1.Toolbar.MainBar.Items.Add(tsbPrint)
        'Create a click event handler for the button.
        AddHandler tsbPrint.Click, AddressOf tsbPrint_Click
    End Sub
    
    'Call the custom dialog from the new button's click event.
    Private Sub tsbPrint_Click(sender As Object, e As EventArgs)
        Me.CustomPrint()
    End Sub
    
    'Call the custom print dialog.
    Private Sub CustomPrint()
        Dim _printForm As New frmPrintDlg()
        _printForm.ShowDialog(Me)
    End Sub
    See Also