ActiveReports 9 > ActiveReports User Guide > How To > Customize, Localize, and Deploy > Customize the FlashViewer Toolbar |
When you use the WebViewer that is licensed with the Professional Edition, one of the ViewerTypes that you can select is FlashViewer. The FlashViewer toolbar is very similar to the Viewer control's toolbar. You can show or hide it, reorder buttons, remove buttons, add custom buttons, or create a custom toolbar. Use the Web.Controls namespace to create custom buttons or a custom toolbar that you can specify in the WebViewer's FlashViewerToolbar property.
The following buttons are provided by default.
Heading | Page Range | |
Search | Zoom-out | Zoom |
Zoom-in | Single Page | Multiple pages |
Continuous Page | Previous Page | Next Page |
Page Number | Backwards | Forward |
Drop down the sections below for code samples.
Note: This code is ignored if the ViewerType property of the WebViewer control is not set to FlashViewer. |
To hide the toolbar
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
WebViewer1.FlashViewerToolBar.Visible = False |
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
WebViewer1.FlashViewerToolBar.Visible = false; |
To add a using or Imports directive
To reduce the amount of code needed for the rest of the customizations, add a using or Imports directive at the top of the ASPX code view.
Paste at the top of the ASPX code view |
Copy Code
|
---|---|
Imports GrapeCity.ActiveReports.Web.Controls |
Paste near the top of the ASPX code view |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Web.Controls; |
To reorder buttons in the toolbar
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
'Get a default tool from the toolbar. (You can also specify the tool index.) Dim tool As ToolBase = WebViewer1.FlashViewerToolBar.Tools("PageRangeButton") 'Remove the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool) 'Insert the tool in a different position. WebViewer1.FlashViewerToolBar.Tools.Insert(0, tool) |
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
//Get a default tool from the toolbar. (You can also specify the tool index.) ToolBase tool = WebViewer1.FlashViewerToolBar.Tools["PageRangeButton"]; //Remove the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool); //Insert the tool in a different position. WebViewer1.FlashViewerToolBar.Tools.Insert(0, tool); |
To remove a button from the toolbar
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
'Get a default tool from the toolbar by name. (You can also specify the tool index.) Dim tool As ToolBase = WebViewer1.FlashViewerToolBar.Tools("PageRangeButton") ' Delete the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool) |
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
//Get a default tool from the toolbar by name. (You can also specify the tool index.) ToolBase tool = WebViewer1.FlashViewerToolBar.Tools["PageRangeButton"]; //Delete the tool from the toolbar. WebViewer1.FlashViewerToolBar.Tools.Remove(tool); |
To create a custom button and add it to the toolbar
Tip: The ToolsCollection class in the Web.Controls namespace has the standard System.Collections.ObjectModel.Collection methods available, so if you want to just add a button to the end of the toolbar, you can use the Add method instead. |
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
Dim customButton As ToolButton = Tool.CreateButton("CustomButton") customButton.Caption = "Contanct Us" customButton.ToolTip = "ActiveReports Website" customButton.ClickNavigateTo = "http://activereports.grapecity.com/" 'Add a button at the specified index. 'An index value of 20 places it second to last, between the Forward and Backward buttons. 'Set the index value to 0 to place it in the first position at the left. WebViewer1.FlashViewerToolBar.Tools.Insert(20, customButton) |
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
ToolButton customButton = Tool.CreateButton("CustomButton"); customButton.Caption = "Contact Us"; customButton.ToolTip = "ActiveReports Website"; customButton.ClickNavigateTo = "http://activereports.grapecity.com/"; //Add a button at the specified index. //An index value of 20 places it second to last, between the Forward and Backward buttons. //Set the index value to 0 to place it in the first position at the left. WebViewer1.FlashViewerToolBar.Tools.Insert(20, customButton); |
To create a custom toolbar and add it to the viewer
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
'Get the collection of buttons and separators used in the toolbar. Dim collection As ToolsCollection = WebViewer1.FlashViewerToolBar.Tools 'Delete all of the buttons and separators from the toolbar. collection.Clear() 'Add pre-defined buttons. collection.Add(Tool.Create(ToolsCollection.ToolCommands.ZoomOutButton)) collection.Add(Tool.Create(ToolsCollection.ToolCommands.ZoomBox)) collection.Add(Tool.Create(ToolsCollection.ToolCommands.ZoomInButton)) ' Add a separator. collection.Add(Tool.CreateSeparator()) 'Add a pre-defined button. collection.Add(Tool.Create(ToolsCollection.ToolCommands.SearchButton)) 'Add a separator. collection.Add(Tool.CreateSeparator()) 'Add custom buttons. collection.Add(Tool.CreateButton("btn1")) collection.Add(Tool.CreateButton("btn2")) |
Paste INSIDE the Page Load event |
Copy Code
|
---|---|
//Get the collection of buttons and separators used in the toolbar. ToolsCollection collection = WebViewer1.FlashViewerToolBar.Tools; //Delete all of the buttons and separators from the toolbar. collection.Clear(); //Add pre-defined buttons. collection.Add(Tool.Create(ToolsCollection.ToolCommands.ZoomOutButton)); collection.Add(Tool.Create(ToolsCollection.ToolCommands.ZoomBox)); collection.Add(Tool.Create(ToolsCollection.ToolCommands.ZoomInButton)); //Add a separator. collection.Add(Tool.CreateSeparator()); //Add a pre-defined button. collection.Add(Tool.Create(ToolsCollection.ToolCommands.SearchButton)); //Add a separator. collection.Add(Tool.CreateSeparator()); //Add custom buttons. collection.Add(Tool.CreateButton("btn1")); collection.Add(Tool.CreateButton("btn2")); |