Custom Properties (Chart Controls)
Each chart type in the Chart control contains a set of custom properties. Custom properties enable you to customize the look and feel of your chart. They are implemented using the CustomProperties property of both the Series objects and their associated DataPoint objects.
Note
Each custom property applies to a specific set of chart types.
Chart control custom properties have the following characteristics:
Depending on the chart type, you can set applicable custom properties to the chart's Series objects or their associated DataPoint objects, or both. If a custom property is applicable to both the chart's Series and DataPoint objects, any custom property that is set for a series is applied to all data points contained within that series.
Custom properties that apply to DataPoint objects have a higher priority than those that apply to Series objects. If the same custom property is set for a Series object and one of its DataPoint objects, the setting for the DataPoint object takes precedence.
Custom property names are case-sensitive.
Custom property values are strings.
If a custom property's value contains a comma, each comma must be preceded by an escape '\' character.
For more information about each custom property, including examples, see Custom Properties List.
Accessing Custom Properties
Custom properties are not visible in the Properties window of Visual Studio. To access them programmatically, you do not need to specify the CustomProperties property. Simply add an indexer to the Series or DataPoint object and use the name of the custom property as the index to get and set the particular name/value pair. This method enables you to access only that particular custom property.
The Series and DataPoint objects provide other methods for accessing custom properties. For example: IsCustomPropertySet, SetCustomProperty, SetCustomProperty, and DeleteCustomProperty.
The following code accesses the Exploded custom property in a pie chart's DataPoint object and sets it to True, and then checks its value:
' Explode the first pie slice
Chart1.Series("Default").Points(0)("Exploded") = "True"
…
' Check if the the first pie slice is still exploded
If Chart1.Series("Default").Points(0)("Exploded") = "True"
' Do something
End If
// Explode the first pie slice
Chart1.Series["Default"].Points[0]["Exploded"] = "True"
…
// Check if the the first pie slice is still exploded
if (Chart1.Series["Default"].Points[0]["Exploded"] == "True")
{
//Do something
}
See Also
Reference
System.Windows.Forms.DataVisualization.Charting
System.Web.UI.DataVisualization.Charting