Articles in this section
Category / Section

How to customize Toolbar items in Chart Control?

1 min read

The WinForms Chart built-in Toolbar can be displayed by setting the ShowToolbar property as true. The toolbar is customized by adding or removing the toolbar Items and customizing the appearance of the toolbar.

 

Customizing Toolbar Items Appearance

The appearance of the chart Toolbar and its items can be customized by using the following properties.

  • ButtonBackColor
  • ButtonForeColor
  • Border style
  • AutoSize
  • ButtonSize
  • Spacing
  • ShowBorder

 

C#

//Show the chart toolbar.
this.chartControl1.ShowToolbar = true;
 
// Specifes ToolBar style
this.chartControl1.ToolBar.AutoSize = true;
this.chartControl1.ToolBar.Border.ForeColor = Color.Blue;
this.chartControl1.ToolBar.BackColor = Color.BlanchedAlmond;
// Specifies the Toolbar Item Style.
this.chartControl1.ToolBar.ButtonBackColor = Color.White;
this.chartControl1.ToolBar.ButtonForeColor = Color.Maroon;

 

Adding Items in chart Toolbar

Add the custom toolbar items by using the ChartToolBarCommandItem in the Toolbar Items collection as shown in the following code example to ZoomIn and ZoomOut.

 

C#

//Adding the custom Toolbar items.
ChartToolBarCommandItem zoomIn = new ChartToolBarCommandItem();
zoomIn.Command = ChartCommands.ZoomIn;
zoomIn.ToolTip = "ZoomIn";
this.chartControl1.ToolBar.Items.Add(zoomIn);
 
ChartToolBarCommandItem zoomOut = new ChartToolBarCommandItem();
zoomOut.Command = ChartCommands.ZoomOut;
zoomOut.ToolTip = "ZoomOut";
this.chartControl1.ToolBar.Items.Add(zoomOut);

 

Output

Customized chart Toolbar with ZoomIn and ZoomOut toolbar items

 

See also

 

How to add custom toolbar commands?

 

How to customize the toolbar appearance?

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied