Chart customize legend event handler delegate.
Visual Basic (Declaration) | |
---|---|
Public Delegate Sub CustomizeLegendEventHandler( _ ByVal sender As Chart, _ ByVal e As CustomizeLegendEventArgs _ ) |
Visual Basic (Usage) | Copy Code |
---|---|
|
C# | |
---|---|
public delegate void CustomizeLegendEventHandler( Chart sender, CustomizeLegendEventArgs e ) |
Parameters
- sender
-
The root Chart object.
- e
-
A CustomizeLegendEventArgs object, used to modify the legend.
The following sample changes the symbol color of the "Sales" series' legend item to red in the "Default" Legend.
Visual Basic | Copy Code |
---|---|
Private Sub Chart1_CustomizeLegend(ByVal chart As Chart, ByVal e As CustomizeLegendEventArgs) _ Handles Chart1.CustomizeLegend If e.Name = "Default" Then 'declare a LegendItem object Dim legendItem As LegendItem For Each legendItem In e.LegendItems If legendItem.SeriesName = "Sales" Then legendItem.Color = Color.Red End If Next End If End Sub |
The declaration of your event handler must have the same parameters as the CustomizeLegendEventHandler delegate declaration.
When you create a CustomizeLegendEventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate.
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