Fires just before the chart legend is drawn. Use this event to customize the chart legend items.
Visual Basic (Declaration) | |
---|---|
Public Event CustomizeLegend() As CustomizeLegendEventHandler |
Visual Basic (Usage) | Copy Code |
---|---|
|
C# | |
---|---|
public event CustomizeLegendEventHandler CustomizeLegend() |
The event handler receives an argument of type CustomizeLegendEventArgs containing data related to this event. The following CustomizeLegendEventArgs properties provide information specific to this event.
Property | Description |
---|---|
LegendItems |
Can be used to remove, modify, and change the order of both custom and default legend items. Custom items can also be added to the legend. Legend items collection. |
LegendName |
Gets the name of the Legend object, which can be used to determine which legend was the sender of the CustomizeLegendEvent. Legend name. |
Visual Basic | Copy Code |
---|---|
Imports Dundas.Charting.WebControl<CRLF>...<CRLF><CRLF>Private Sub Chart1_CustomizeLegend(ByVal chart As Chart, ByVal e As CustomizeLegendEventArgs) _<CRLF>Handles Chart1.CustomizeLegend<CRLF><CRLF> 'declare a LegendItem object<CRLF> Dim legendItem As LegendItem<CRLF> <CRLF> For Each legendItem In e.LegendItems<CRLF> If legendItem.SeriesName = "Sales" Then<CRLF> legendItem.Color = Color.Red<CRLF> End If<CRLF> Next<CRLF> <CRLF>End Sub |
The CustomizeLegend event is primarily used to customize the legend just prior to being drawn. Both default and custom legend items can be removed or modified, and custom items can also be added. In addition the order of legend items can be changed.
The chart image can also be modified before being drawn using the sender argument.
Note that a "default" legend item is an item that is created for either a data series or data point, while a "custom" legend item is not connected in any way to the chart's data. For an explanation of "default" versus "custom" legend items see the Default and Legend Items and Custom Legend Items topics.
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family