# Attaching the Chart Label by Data Point

## Content



To attach a ChartLabel to a data point, set the **AttachMethod** property to AttachMethodEnum.DataIndex, and then under the AttachMethodData object set the **GroupIndex**, **SeriesIndex**, and **PointIndex** properties. These properties specify the ChartGroup, Series, and Point indices. PointIndex refers to the element of the data array. SeriesIndex refers to the element of the series array. Each series has arrays of data.

The following code example attaches a ChartLabel to a data point:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
With C1Chart1.ChartLabels.LabelsCollection(0)
    .AttachMethod = AttachMethodEnum.DataIndex
    .AttachMethodData.GroupIndex = 0
    .AttachMethodData.SeriesIndex = 1
    .AttachMethodData.PointIndex = 2
End With
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
C1.Win.C1Chart.Label lab = c1Chart1.ChartLabels.LabelsCollection[0];
lab.AttachMethod = AttachMethodEnum.DataIndex;
lab.AttachMethodData.GroupIndex = 0;
lab.AttachMethodData.SeriesIndex = 1;
lab.AttachMethodData.PointIndex = 2;
```

DOC-DETAILS-TAG-CLOSE

For more information on how to attach the chart label by data point at design time see, Attach by Data Index.

## See Also

[Attaching the Chart Label by Data Point and Y Value](/componentone/docs/win/online-chart2d/chartinglabels/attachingandposition/attachingthechartlab3)