---
title: "how do you bind datagridview with chart?"  
description: "how do you bind datagridview with chart?"  
author: "Ho Hui Jun"  
published: 2015-12-29  
updated: 2016-01-08  
canonical: https://www.mindstick.com/forum/33805/how-do-you-bind-datagridview-with-chart  
category: "c#"  
tags: ["chart", "datagridview"]  
reading_time: 3 minutes  

---

# how do you bind datagridview with chart?

hi there, I really need help on this [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) that I am dealing with. It is to calculate [free](https://www.mindstick.com/articles/12963/3-free-things-to-do-in-valletta) [surface](https://www.mindstick.com/forum/907/how-to-surface-a-value-for-more-than-one-row-in-mysql) [effect](https://yourviews.mindstick.com/view/81363/coronavirus-effect-on-american-farms-is-severe) of a vessel on [large](https://www.mindstick.com/interview/34471/what-is-a-large-language-model-llm) angle which I have no idea where it when wrong.\
![how do you bind datagridview with chart?](https://www.mindstick.com/mindstickforums/2a92c7e7-4949-467f-9c2e-0aa391ae1892/images/0153dfff-006e-458d-a270-52a835451b08.png)it doesn't show any chart on the right side. below is the code for the chart. I do appreciate if anyone could help me with this.\

```
Private Sub GZChart_Click(sender As Object, e As EventArgs) Handles GZChart.Click        GZChart.ChartAreas.Add("area")        GZChart.ChartAreas("area").AxisX.Minimum = 0        GZChart.ChartAreas("area").AxisY.Minimum = 0        GZChart.ChartAreas("area").AxisX.Maximum = 100        GZChart.ChartAreas("area").AxisY.Maximum = 20        GZChart.ChartAreas("area").AxisX.Interval = 10        GZChart.ChartAreas("area").AxisX.Interval = 0.5        GZChart.Series("Series1").Color = Color.Red        GZChart.Series("Series1").ChartType = DataVisualization.Charting.SeriesChartType.SplineArea        GZChart.Series.Clear()        GZChart.Series.Add("Series1")        GZChart.Series("Series1").Points.Clear()        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(0).Cells(1).Value, DataGridView.Rows(0).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(1).Cells(1).Value, DataGridView.Rows(1).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(2).Cells(1).Value, DataGridView.Rows(2).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(3).Cells(1).Value, DataGridView.Rows(3).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(4).Cells(1).Value, DataGridView.Rows(4).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(5).Cells(1).Value, DataGridView.Rows(5).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(6).Cells(1).Value, DataGridView.Rows(6).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(7).Cells(1).Value, DataGridView.Rows(7).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(8).Cells(1).Value, DataGridView.Rows(8).Cells(3).Value)        GZChart.Series("Series1").Points.AddXY(DataGridView.Columns(3).HeaderText & "--", DataGridView.Rows(9).Cells(1).Value, DataGridView.Rows(9).Cells(3).Value)    End Sub
```

\

## Replies

### Reply by Ho Hui Jun

Hi, Pawan Shukla\
Thank you so much , it helps alot.

### Reply by Anonymous User

Hi.\
Step -1 Craete a class\

```
        public class Product        {            public string ProductName { get; set; }            public int Qty { get; set; }            public float Price { get; set; }        }
```

\
Step-2Add dummy record in list and bind to datagridview\

```
            List<Product> list = new List<Product>();            list.Add(new Product { ProductName = "Pendrive", Qty = 10, Price = 323 });            list.Add(new Product { ProductName = "Laptop", Qty = 23, Price = 1445 });            list.Add(new Product { ProductName = "Computer", Qty = 34, Price = 1446 });            DGV1.DataSource = list;
```

\
Step-3Add Series to chart and bind data from datagridview\

```
            chart1.Series.Clear();            chart1.Series.Add("Pendrive");            chart1.Series.Add("Laptop");            chart1.Series.Add("Computer");            chart1.Series["Pendrive"].Points.Clear();            chart1.Series["Pendrive"].Points.AddXY("Product", DGV1.Rows[0].Cells[1].Value);            chart1.Series["Laptop"].Points.Clear();            chart1.Series["Laptop"].Points.AddXY("Product", DGV1.Rows[1].Cells[1].Value);            chart1.Series["Computer"].Points.Clear();            chart1.Series["Computer"].Points.AddXY("Product", DGV1.Rows[2].Cells[1].Value);
```

Output:![how do you bind datagridview with chart?](https://www.mindstick.com/mindstickforums/2a92c7e7-4949-467f-9c2e-0aa391ae1892/images/bc2da2d3-a248-4d11-a239-e788fbcb3442.png)\
\


---

Original Source: https://www.mindstick.com/forum/33805/how-do-you-bind-datagridview-with-chart

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
