Class ChartLegendItem
The ChartLegendItem class holds information about each legend item like text, color and interior. Use this to add custom legend items through the ChartLegend.CustomItems list. Or parse through the auto generated ChartLegend.Items list.
Implements
Inherited Members
Namespace: Syncfusion.Windows.Forms.Chart
Assembly: Syncfusion.Chart.Base.dll
Syntax
public class ChartLegendItem : IDisposable
Constructors
ChartLegendItem()
Overloaded constructor.
Declaration
public ChartLegendItem()
ChartLegendItem(String)
Overloaded constructor.
Declaration
public ChartLegendItem(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text of item. |
Fields
m_textHandler
Declaration
public LegendDrawItemTextEventHandler m_textHandler
Field Value
Type |
---|
LegendDrawItemTextEventHandler |
Properties
Border
Gets or sets the border item that is to be associated with this item's border.
Declaration
public ChartLineInfo Border { get; set; }
Property Value
Type |
---|
ChartLineInfo |
BorderColor
Gets or sets the color of the border.
Declaration
public Color BorderColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
Bounds
Gets the rendering bounds of the ChartLegendItem.
Declaration
public RectangleF Bounds { get; }
Property Value
Type |
---|
System.Drawing.RectangleF |
Children
Returns the the child collection.
Declaration
public ChartLegendItemsCollection Children { get; }
Property Value
Type |
---|
ChartLegendItemsCollection |
Font
Gets or sets the font of the text.
Declaration
public Font Font { get; set; }
Property Value
Type |
---|
System.Drawing.Font |
IconAlignment
Gets or sets the left/right alignment of the icon with respect to the legend text.
Declaration
public LeftRightAlignment IconAlignment { get; set; }
Property Value
Type |
---|
System.Windows.Forms.LeftRightAlignment |
Image
Gets or sets the icon image.
Declaration
public Image Image { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Image | The image. |
ImageIndex
Gets or sets the image index value of the item in the item's image list.
Declaration
public int ImageIndex { get; set; }
Property Value
Type |
---|
System.Int32 |
ImageList
Gets or sets the ImageList associated with this item.
Declaration
public ChartImageCollection ImageList { get; set; }
Property Value
Type |
---|
ChartImageCollection |
Interior
Gets or sets the interior brush for the rectangular area that represents a legend.
Declaration
public BrushInfo Interior { get; set; }
Property Value
Type |
---|
BrushInfo |
IsChecked
Gets or sets the state of ChartLegendItem checkbox.
Declaration
public bool IsChecked { get; set; }
Property Value
Type |
---|
System.Boolean |
ItemStyle
Returns the ChartLegendItemStyle for this item.
Declaration
public ChartLegendItemStyle ItemStyle { get; }
Property Value
Type |
---|
ChartLegendItemStyle |
RepresentationSize
Gets or sets the size of the rectangle holding the representation icon of the item.
Declaration
public Size RepresentationSize { get; set; }
Property Value
Type |
---|
System.Drawing.Size |
ShadowColor
Gets or sets the color of the Shadow.
Declaration
public Color ShadowColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
ShadowOffset
Gets or sets the size of shadow offset.
Declaration
public Size ShadowOffset { get; set; }
Property Value
Type |
---|
System.Drawing.Size |
ShowIcon
Indicates whether the icon is to be displayed.
Declaration
public bool ShowIcon { get; set; }
Property Value
Type |
---|
System.Boolean |
ShowShadow
Indicates if the shadow is to be shown.
Declaration
public bool ShowShadow { get; set; }
Property Value
Type |
---|
System.Boolean |
ShowSymbol
Indicates whether the symbol is to be displayed.
Declaration
public bool ShowSymbol { get; set; }
Property Value
Type |
---|
System.Boolean |
Spacing
Gets or sets the spacing of the item within the legend.
Declaration
public int Spacing { get; set; }
Property Value
Type |
---|
System.Int32 |
Symbol
Gets or sets the symbol that is to be associated with this item.
Declaration
public ChartSymbolInfo Symbol { get; set; }
Property Value
Type |
---|
ChartSymbolInfo |
Text
Gets or sets the text of the item.
Declaration
public string Text { get; set; }
Property Value
Type |
---|
System.String |
TextAligment
Gets or sets the vertical alignment of the legend text.
Declaration
public VerticalAlignment TextAligment { get; set; }
Property Value
Type |
---|
VerticalAlignment |
TextColor
Gets or sets the color of the text of the item.
Declaration
public Color TextColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
TextLines
Gets or sets the lines of text in multiline configurations.
Declaration
public string[] TextLines { get; set; }
Property Value
Type |
---|
System.String[] |
Type
Gets or sets the type of representation for the legend item.
Declaration
public ChartLegendItemType Type { get; set; }
Property Value
Type |
---|
ChartLegendItemType |
Visible
Gets or sets value indicates whether ChartLegendItem is visible.
Declaration
public bool Visible { get; set; }
Property Value
Type |
---|
System.Boolean |
VisibleCheckBox
Indicates if the checkbox associated with this legend item is to be displayed. Also see IsChecked.
Declaration
public bool VisibleCheckBox { get; set; }
Property Value
Type |
---|
System.Boolean |
Methods
Arrange(RectangleF)
Sets the bounds of ChartLegendItem.
Declaration
public void Arrange(RectangleF rect)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rect |
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
DisposeLegendItem()
Disposes legend item object
Declaration
public void DisposeLegendItem()
Draw(Graphics)
Draws the ChartLegendItem.
Declaration
public void Draw(Graphics g)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g |
Draw(Graphics, Pen, RectangleF, StringFormat)
Draws the ChartLegendItem.
Declaration
public void Draw(Graphics g, Pen borderPen, RectangleF bounds, StringFormat format)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Graphics object |
System.Drawing.Pen | borderPen | RectangleF object. Legend item border will be drawn with this Pen. If border is not required pass null as value for this parameter |
System.Drawing.RectangleF | bounds | RectangleF object. Legend item will be drawn within the bounds of this rectangle |
System.Drawing.StringFormat | format | StringFormat object. Legend item text will be drawn in the specified string format |
IsHit(Int32, Int32)
Indicates if ChartLegendItem contains the specified coordinates.
Declaration
public bool IsHit(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y |
Returns
Type |
---|
System.Boolean |
Measure(Graphics)
Measures the size of ChartLegendItem.
Declaration
public SizeF Measure(Graphics g)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g |
Returns
Type |
---|
System.Drawing.SizeF |
Measure(Graphics, Rectangle)
Measures the size of ChartLegendItem.
Declaration
public SizeF Measure(Graphics g, Rectangle bounds)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Graphics object used for drawing the legend item |
System.Drawing.Rectangle | bounds | Rectangle defining the bounds of legend item |
Returns
Type |
---|
System.Drawing.SizeF |
SetLegend(IChartLegend)
Sets the legend.
Declaration
public void SetLegend(IChartLegend legend)
Parameters
Type | Name | Description |
---|---|---|
IChartLegend | legend | The legend. |
Events
Changed
Raised when properties are changed.
Declaration
public event EventHandler Changed
Event Type
Type |
---|
System.EventHandler |
CheckedChanged
Raised when IsChecked property is changed.
Declaration
public event EventHandler CheckedChanged
Event Type
Type |
---|
System.EventHandler |