How to Customize the ComponentOne FlexPivot Toolbar
The ComponentOne Studio WinForms Edition offers a FlexPivot control that is a powerful data analysis tool. This control displays a toolbar, allowing the user to perform different operations at runtime (such as loading view, saving current view to a file, exporting data to Excel, and customizing a grid view).
There are instances when you'll need to customize this toolbar. Recently, we came across a customer that needed to show the default file name in the Save Dialog Box when the user clicks the save button. It's not directly possible to change the default behavior of any button on the toolbar. However, the button can be replaced with a new button that will show the required behavior.
As C1FlexPivot uses the C1ToolBar instance as its toolbar, it offers the desired flexibility. So, let's examine how to achieve this functionality.
We need to add a new CommandLink and remove the existing one to save the file.
First, we create a new CommandLink that looks same as the existing Save CommandLink in appearance. Then, we remove the older one from the toolbar.
Now, we'll need to show the Save Dialog Box when this new CommandLink has been clicked. CommandClick event of CommandHolder helps us with this, where we're also using the FileName property of the Save Dialog Box to set a default name for the saved file.
Further, we're calling WriteXml method of C1FlexPivotPage in order to save the current view to file when the user clicks on the ‘OK’ button in the Save Dialog Box. Similarly, we can customize any button on this toolbar as needed.
If you have any questions please post below.
Happy Programming!