# Creating a Gradient Brush

## Content



The following sample code represents the handler that creates linear gradient brush.

Please note that the given code snippet shows the initial declarations of some objects using their full namespace. In subsequent use of those and related objects, the namespace is omitted for brevity.

DOC-DETAILS-TAG-OPEN

DOC-SUMMARY-TAG-OPEN

To write code in Visual Basic

DOC-SUMMARY-TAG-CLOSE

```vbnet
Private Sub C1Chart1_DrawDataSeries(ByVal sender As Object, _     ByVal e As C1.Win.C1Chart.DrawDataSeriesEventArgs) _    Handles C1Chart1.DrawDataSeries
  Dim ds As C1.Win.C1Chart.ChartDataSeries = sender    
  Dim clr1 As Color = ds.LineStyle.Color
  Dim clr2 As Color = ds.SymbolStyle.Color  
  If(e.Bounds.Height > 0 And e.Bounds.Width > 0) Then    Dim lgb As System.Drawing.Drawing2D.LinearGradientBrush = _       New LinearGradientBrush(e.Bounds, clr1, clr2, LinearGradientMode.Horizontal)    e.Brush = lgb
  End If 
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 c1Chart1_DrawDataSeries(object sender,    
   C1.Win.C1Chart.DrawDataSeriesEventArgs e)      
{      
  C1.Win.C1Chart.ChartDataSeries ds = (ChartDataSeries)sender;   
  Color clr1 = ds.LineStyle.Color;   
  Color clr2 = ds.SymbolStyle.Color;
  if(e.Bounds.Size.Height > 0 && e.Bounds.Size.Width > 0)
  {   
    System.Drawing.Drawing2D.LinearGradientBrush lgb =       new LinearGradientBrush(e.Bounds, clr1, clr2, LinearGradientMode.Horizontal);  
    e.Brush = lgb;
  } 
}
```

DOC-DETAILS-TAG-CLOSE

The following image shows the linear gradient brush:

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

## See Also

[Loading and Saving Charts, Data, and Images](/componentone/docs/win/online-chart2d/loadingandsavingchar)