---
title: "Working with chart in C#"  
description: "In this article I am trying to make a small demo and explain the concept of chart in C#."  
author: "Vijay Shukla"  
published: 2013-06-18  
updated: 2020-02-03  
canonical: https://www.mindstick.com/articles/1337/working-with-chart-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Working with chart in C#

## Working with a chart in C#

Here, In this article, I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to make a small demo and [explain the concept](https://www.mindstick.com/forum/158822/explain-the-concept-of-abstract-classes-and-their-significance-in-oop) of a chart in C#.\

##### Chart

The chart is a graphical representation of data, charts allow users to see what the result of various data is to better understand and predict current and future data.

##### Steps for creating a demo project:-

- Create a new project New >> Project (give the appropriate name of the project).
- Now by default show a form1, in form1 [drag and drop](https://www.mindstick.com/forum/454/how-to-drag-and-drop-multiple-image-from-one-canvas-to-onther-canvas-in-html5) a datagridview where add the information for a chart.
- After added datagridview drag and drop the chart from the toolbox.
- After adding chart Goto on its [property](https://www.mindstick.com/articles/198559/an-ownership-of-property-in-hua-hin) and click on the series property open its [dialog box](https://www.mindstick.com/blog/157/dialog-box-in-dot-net) and rename the series (I rename the series into StudentScore).

![Working with chart in C#](https://www.mindstick.com/mindstickarticle/496b452d-9348-40e1-9768-db5819983e0f/images/f61f08eb-d0a8-4a31-8d08-3cfc8b773094.png)

- Now [double click](https://www.mindstick.com/forum/156225/differentiate-between-google-adword-and-double-click) on the form1 and get the form load event.
- After getting form load event write the code in the form load event.

```
 private void Form2_Load(object sender, EventArgs e)
 {
 try
 {
 dataGridView1.Rows.Add("alex stewart", 24, 56);
 dataGridView1.Rows.Add("chris harris", 34, 76);
 dataGridView1.Rows.Add("frank smith", 21, 46);
 dataGridView1.Rows.Add("henry paul", 27, 66);
 dataGridView1.Rows.Add("lan bishop", 31, 59);
 for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
 {                  this.chart1.Series["StudentScore"].Points.AddXY(dataGridView1.Rows[i].Cells[0].Value.ToString(), Convert.ToInt32(dataGridView1.Rows[i].Cells[2].Value.ToString()));
 }
 }
 catch (Exception ex)
 {
 MessageBox.Show("something is wrong");
 }
 }
```

## Code Description:-

- This is a form load event.
- To 9. Add [data in datagridview](https://www.mindstick.com/forum/33964/insert-data-in-datagridview-from-text-box-c-sharp).
- This is [for loop](https://www.mindstick.com/forum/857/nested-for-loop-in-java-for-a-triangle) it will run while datagridview rows count.
- This line of code will [add data](https://www.mindstick.com/forum/287/how-to-add-data-in-drop-down-list) in a chart from datagridview.

##### Output:-

![Working with chart in C#](https://www.mindstick.com/mindstickarticle/496b452d-9348-40e1-9768-db5819983e0f/images/cff606bc-636f-4229-8571-8e64a4b2b565.png)

\

You should also read this Article - **[Search Functionality in ASP.NET MVC 4](https://www.mindstick.com/Articles/1141/search-functionality-in-asp-dot-net-mvc-4)**

---

Original Source: https://www.mindstick.com/articles/1337/working-with-chart-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
