Back to Devexpress

ChartElementNamedCollection.GetElementByName(String) Method

corelibraries-devexpress-dot-xtracharts-dot-chartelementnamedcollection-dot-getelementbyname-x28-system-dot-string-x29.md

latest3.7 KB
Original Source

ChartElementNamedCollection.GetElementByName(String) Method

Gets an element within the collection by its name.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public ChartElementNamed GetElementByName(
    string name
)
vb
Public Function GetElementByName(
    name As String
) As ChartElementNamed

Parameters

NameTypeDescription
nameString

A String which specifies the name of the element to find.

|

Returns

TypeDescription
ChartElementNamed

A ChartElementNamed object that represents the element with the specified name.

|

Remarks

Note that this method finds only the first occurrence of an element with the specified name. If no element with the specified name is found, then this method returns null ( Nothing in Visual Basic).

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetElementByName(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-chart-add-an-additional-legend-to-a-chart/CS/LegendsSamples/Form1.cs#L30

csharp
if(view == null) return;
Indicator macd = view.Indicators.GetElementByName("MACD") as Indicator;

winforms-chart-accompany-chart-elements-by-text-or-image-annotations/VB/AnnotationsSample/Form1.vb#L47

vb
' or centrally, via the chart control's repository (e.g. by its name).
Dim myTextAnnotation As TextAnnotation = CType(chartControl1.AnnotationRepository.GetElementByName("Annotation 1"), TextAnnotation)
Dim myImageAnnotation As ImageAnnotation = CType(chartControl1.AnnotationRepository.GetElementByName("Annotation 3"), ImageAnnotation)

winforms-chart-add-an-additional-legend-to-a-chart/VB/LegendsSamples/Form1.vb#L33

vb
If view Is Nothing Then Return
            Dim macd As Indicator = TryCast(view.Indicators.GetElementByName("MACD"), Indicator)
#Region "#AddAdditionalLegend"

See Also

ChartElementNamedCollection Class

ChartElementNamedCollection Members

DevExpress.XtraCharts Namespace