LegendItem 类

定义

表示一个图例项,它存储在 LegendItemsCollection 类中。Represents a legend item, which is stored in the LegendItemsCollection class.

public ref class LegendItem : System::Windows::Forms::DataVisualization::Charting::ChartNamedElement
public class LegendItem : System.Windows.Forms.DataVisualization.Charting.ChartNamedElement
type LegendItem = class
    inherit ChartNamedElement
Public Class LegendItem
Inherits ChartNamedElement
继承

注解

LegendItem类表示一个图例项, 可以是默认项或自定义项:The LegendItem class represents a legend item, which can be either a default or custom item:

  • 默认图例项自动插入到数据序列或数据点的图例中。Default legend items are automatically inserted into the legend for either data series or data points. 饼图和圆环图的默认条目表示绘制的数据点, 而所有其他图表类型的条目表示绘制的序列。Default entries for pie and doughnut charts represent the plotted data points, whereas entries for all other chart types represent the plotted series. 默认情况下, 这些图例项对符号颜色使用数据点或序列颜色, 并使用图例项文本的序列或数据点的名称。By default, these legend entries use the data point or series color for the symbol color, and the name of the series or data point for the legend item text. 可以在运行时使用CustomizeLegend Chart控件的事件自定义或删除默认图例项。Default legend items can be customized or deleted at run time by using the CustomizeLegend event of the Chart control.

  • 自定义图例项具有用户定义的文本、符号颜色等。Custom legend items have user-defined text, symbol color, and so forth. 与默认项不同, 它们不与绘制的数据连接。Unlike the default entries, they are not connected with the plotted data. 使用CustomItems Legend对象的属性可以在设计时或运行时添加自定义图例项。Custom legend items can be added at either design time or run time, using the CustomItems property of the Legend object.

图例符号可以是矩形、线条或标记, 具体取决于ImageStyle LegendItem对象的属性设置。Legend symbols can be rectangles, lines or markers, depending on the ImageStyle property setting of a LegendItem object.

自定义图例项的文本由Name属性确定。The text of a custom legend item is determined by the Name property.

构造函数

LegendItem()

初始化 LegendItem 类的新实例。Initializes a new instance of the LegendItem class.

LegendItem(String, Color, String)

使用指定的名称、颜色和图像路径初始化 LegendItem 类的新实例。Initializes a new instance of the LegendItem class with the specified name, color and image path.

属性

BackGradientStyle

获取或设置图例项的背景渐变的方向。Gets or sets the orientation for the background gradient of a legend item. 还确定是否使用渐变。Also determines whether a gradient is used.

BackHatchStyle

获取或设置图例项的阴影样式。Gets or sets the hatching style of a legend item.

BackImageTransparentColor

获取或设置在绘制背景图像时,将替换为透明色的颜色。Gets or sets a color which will be replaced with a transparent color when the background image is drawn.

BackSecondaryColor

获取或设置图例项的辅助颜色。Gets or sets the secondary color of a legend item.

BorderColor

获取或设置图例项的边框颜色。Gets or sets the border color of a legend item.

BorderDashStyle

获取或设置图例项的边框样式。Gets or sets the border style of a legend item.

BorderWidth

获取或设置图例项的边框宽度。Gets or sets the border width of a legend item.

Cells

获取图例项单元的集合。Gets the collection of cells in the legend item.

Color

获取或设置图例项的颜色。Gets or sets the color of a legend item.

Enabled

获取或设置一个标志,该标志指示是否启用图例项。Gets or sets a flag that indicates whether the legend item is enabled.

Image

获取或设置将为图例项符号显示的图像。Gets or sets the image that will be displayed for a legend item symbol.

ImageStyle

获取或设置图例项图像的显示样式。Gets or sets the display style of the legend item image.

Legend

获取或设置与此图例项关联的 Legend 对象。Gets or sets the Legend object associated with this legend item.

MarkerBorderColor

获取或设置标记的边框颜色(如果使用)。Gets or sets the border color of the markers, if used.

MarkerBorderWidth

获取或设置标记的边框宽度(如果使用)。Gets or sets the border width of the markers, if used. 以像素度量。Measured in pixels.

MarkerColor

获取或设置标记的颜色(如果使用)。Gets or sets the color of the markers, if used.

MarkerImage

获取或设置图例项的标记图像。Gets or sets a marker image of the legend item.

MarkerImageTransparentColor

获取或设置在绘制标记图像时,将替换为透明色的颜色。Gets or sets a color that will be replaced with a transparent color when the marker image is drawn.

MarkerSize

获取或设置图例项标记的大小(如果使用)。Gets or sets the size of the legend item markers, if used.

MarkerStyle

获取或设置图例项标记样式。Gets or sets a legend item marker style. 也用于启用或禁用标记的显示。Also used to enable or disable the display of markers.

Name

获取或设置图例项的名称。Gets or sets the name of the legend item.

SeparatorColor

获取或设置图例项分隔符的颜色。Gets or sets the color of the legend item separator.

SeparatorType

获取或设置图例项的分隔符样式。Gets or sets the separator style of the legend item.

SeriesName

获取或设置与默认图例项关联的 Series 的名称。Gets or sets the name of the Series associated with a default legend item.

SeriesPointIndex

获取或设置与默认图例项关联的 DataPoint 对象的索引。Gets or sets the index of a DataPoint object associated with a default legend item.

ShadowColor

获取或设置图例项的阴影颜色。Gets or sets the shadow color of a legend item.

ShadowOffset

获取或设置图例项的阴影偏移量(以像素为单位)。Gets or sets the shadow offset, in pixels, of a legend item.

Tag

获取或设置与此图表元素关联的对象。Gets or sets an object associated with this chart element.

(继承自 ChartElement)
ToolTip

获取或设置图例项的工具提示。Gets or sets the tooltip of the legend item.

方法

Dispose()

释放由 ChartElement 占用的资源。Releases the resources used by the ChartElement.

(继承自 ChartElement)
Dispose(Boolean)

释放由 LegendItem 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the LegendItem and optionally releases the managed resources.

Equals(Object)

确定指定的 Object 是否等同于当前的 ChartElementDetermines whether the specified Object is equal to the current ChartElement.

(继承自 ChartElement)
GetHashCode()

返回特定类型的哈希算法。Returns a hash function for a particular type.

(继承自 ChartElement)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前 Object 的字符串。Returns a string that represents the current Object.

(继承自 ChartElement)

适用于