All Controls


Adding a New Chart to a Project via Code

In order to add a chart via code, we will first need to add a reference to the DLL. Then we can programmatically create a new chart.

Add the DLL Reference

In the Solution Explorer, add a reference to the VDISPCWIN.dll, which can be purchased or a demo may be downloaded. To add a reference to the DLL, right-click on the References item and select Add Reference...:

Add reference

In the dialog that comes up, go to the Browse tab and navigate to the location of the VDISPCWIN.dll. Select OK and the reference will be added:

Reference dialog

Programmatically Create Chart

Before we add the chart, we need to include the necessary namespaces for the controls.

Below, we will programmatically create an Individuals chart (named indChart in the examples below). The process is similar for the other charts:

[Visual Basic]
' Create an individuals chart
Dim indChart As New IndChart()

[Visual C#]
// Create an individuals chart
IndChart indChart = new IndChart();