# Creating Custom PointStyles

## Content



To define custom point style condition the user must set [Selection](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.PointStyle.Selection.html) property of PointStyle to **PointStyleSelectionEnum.Custom** and provide event handler for the [Select](/componentone/api/win/online-chart2d/dotnet-framework-api/C1.Win.C1Chart.4.8/C1.Win.C1Chart.PointStyle.Select.html) event. The following code creates a custom point style:

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)_ Handles Button1.Click  
         ' create point style    
        Dim ps As C1.Win.C1Chart.PointStyle = New C1.Win.C1Chart.PointStyle()   
         ' custom point style  
        ps.Selection = C1.Win.C1Chart.PointStyleSelectionEnum.Custom 
        AddHandler ps.Select, AddressOf PS_Select   
          ' add point style   
        c1Chart1.ChartGroups(0).ChartData.PointStylesList.Add(ps)  
End Sub       
Private Sub PS_Select(ByVal sender As Object, ByVal e As _   C1.Win.C1Chart.PointStyleSelectEventArgs)    
        Dim ps As C1.Win.C1Chart.PointStyle = CType(sender, C1.Win.C1Chart.PointStyle)  
          ' set visual appearance depending on y value    
        Dim ds As C1.Win.C1Chart.ChartDataSeries = _   c1Chart1.ChartGroups(0).ChartData(e.SeriesIndex)   
        Dim y As Double = Convert.ToDouble(ds.Y(e.PointIndex))    
        If (y < 0) Then  
                ps.LineStyle.Color = Color.Blue 
        Else 
                ps.LineStyle.Color = Color.Red    
        End If  
          ' apply to all points   
        e.Selected = True  
End Sub
```

DOC-DETAILS-TAG-CLOSE

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in C#

DOC-SUMMARY-TAG-CLOSE

```csharp
private void button1_Click(object sender, System.EventArgs e)   
{      
   // create point style       
  C1.Win.C1Chart.PointStyle ps = new C1.Win.C1Chart.PointStyle();    
   // custom point style      
  ps.Selection = C1.Win.C1Chart.PointStyleSelectionEnum.Custom;   
  ps.Select += new C1.Win.C1Chart.PointStyleSelectEventHandler(PS_Select);     
   // add point style      
  c1Chart1.ChartGroups[0].ChartData.PointStylesList.Add( ps);    
}
private void PS_Select( object sender, C1.Win.C1Chart.PointStyleSelectEventArgs e)       
{      
        C1.Win.C1Chart.PointStyle ps = sender as C1.Win.C1Chart.PointStyle;     
         // set visual appearance depending on y value       
        C1.Win.C1Chart.ChartDataSeries ds = c1Chart1.ChartGroups[0].ChartData[e.SeriesIndex];     
        double y = Convert.ToDouble( ds.Y[e.PointIndex]);     
        if( y<0)   
                ps.LineStyle.Color = Color.Blue;     
        else    
                ps.LineStyle.Color = Color.Red;   
         // apply to all points      
        e.Selected = true;   
}
```

DOC-DETAILS-TAG-CLOSE

A custom blue point style is created for Y values less than zero and a custom red point style is created for y values greater than zero.

![](https://cdn.mescius.io/document-site-files/images/70bd33a2-280e-4cc3-a1c0-7b827eceb8aa/imagesext/image9_172.png)

## See Also

[Data Binding](/componentone/docs/win/online-chart2d/databinding)