GrapeCity.ActiveReports.Viewer.Win.v9 Assembly > GrapeCity.ActiveReports.Viewer.Win Namespace > Viewer.ViewerToolbar Class : MainBar Property |
'Declaration Public ReadOnly Property MainBar As System.Windows.Forms.ToolStrip
public System.Windows.Forms.ToolStrip MainBar {get;}
Items on this toolstrip and their index numbers:
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.
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