You can hide or enumerate (for Window Forms only) toolbar items and add custom buttons to the ActiveAnalysis toolbar. Use the ToolbarPartSettings class to customize the toolbar items.
When you customize the ActiveAnalysis toolbar, you can modify its items individually or in groups. You can show or hide an item or group, enumerate (for Window Forms only) and expand the toolbar by adding new buttons. The buttons available in the toolbar are categorized into following groups:
- Layout: Clear layout, Open layout, Save layout buttons.
- Export view: Print preview, Copy, Export to buttons.
- UndoRedo: Undo, Redo buttons.
- Execution: Auto query, Execute query buttons.
- ViewSettings: SwapXY, Toggle schema, Toggle shelves, Cards, Grid settings, Format, Auto show legends buttons.
To enumerate existing toolbar items (for Window Forms projects only)
These steps assume that you have created a viewer and have an RdDataSource with a data connection in place.
- In the code view of the form containing your PivotView control, add the code like the following:
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste ABOVE the class. Copy Code Imports GrapeCity.ActiveAnalysis.Windows.Forms
Imports ToolbarButton=GrapeCity.ActiveAnalysis.Windows.Forms.ToolbarButtonC# code. Paste ABOVE the class. Copy Code using GrapeCity.ActiveAnalysis.Windows.Forms;
using ToolbarButton=GrapeCity.ActiveAnalysis.Windows.Forms.ToolbarButton; - In the design view of the form containing your PivotView control, from the Visual Studio toolbox, drag a button onto the blank area on the right side of the PivotView toolbar.
- Double-click the button to go to the code view and create a Button_Click event.
- Add code like the following to the Click event:
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Button_Click event. Copy Code 'Set the button image to the PivotView clear layout toolbar button image button1.Image = (CType(pivotView1.ToolbarSettings(ToolbarParts.Layout).Items.First(), ToolbarButton)).Image 'call the PivotView "Clear" ToolBar button event Dim Handler As Action(Of PivotView) = (CType(pivotView1.ToolbarSettings(ToolbarParts.Layout).Items.First(), ToolbarButton)).Handler Handler(pivotView1)
C# code. Paste INSIDE the Button_Click event. Copy Code //Set the button image to the PivotView clear layout toolbar button image button1.Image = ((ToolbarButton)(pivotView1.ToolbarSettings[ToolbarParts.Layout].Items.First())).Image; //call the PivotView "Clear" ToolBar button event ((ToolbarButton)(pivotView1.ToolbarSettings[ToolbarParts.Layout].Items.First())).Handler(pivotView1);
To hide an individual toolbar item (for Window Forms projects only)
These steps demonstrate hiding the first item (Clear Layout) in the Layout group of the toolbar. These steps assume that you have already created a viewer.
- In the code view of the form, add the following Imports/using statements:
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste ABOVE the class. Copy Code Imports GrapeCity.ActiveAnalysis.Windows.Forms
C# code. Paste ABOVE the class. Copy Code using GrapeCity.ActiveAnalysis.Windows.Forms;
- In the design view of the form, double-click the form containing the PivotView control to create an instance of Form_Load event.
- Add code like the following to the Form_Load event:
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Form_Load event. Copy Code 'Hide the Clear Layout toolbar button DirectCast(PivotView1.ToolbarSettings(ToolbarParts.Layout).Items.ElementAt(0), ToolbarButton).Visible = False
C# code. Paste INSIDE the Form_Load event. Copy Code //Hide the Clear Layout toolbar button ((ToolbarButton)pivotView1.ToolbarSettings[ToolbarParts.Layout].Items.ElementAt(0)).Visible = false;