How to Use Chart Graph in Windows Application

Here, I will explain how to use a Chart Graph a Windows application.

Step 1: Form

Drag and drop a chart graph and a button from the ToolBox.

chart graph

You can change the properties of this chart graph. The main property of this chart graph is "collection".

From this we set the Graph as a X-axis and Y-axis. Here I am making a graph of age and score.You can change the color and background image.
 
change color and background image

Step 2: Code

Click on the button and write the following code.
 
code
  1. Private void Chart_btn_Click(object sender, Event args)  
  2. {  
  3.     this.chart1.Series["Age"].Points.AddXY("max",33);  
  4.     this.chart1.Series["Score"].Points.AddXY("max",93);  
  5.     this.chart1.Series["Age"].Points.AddXY("carl",20);  
  6.     this.chart1.Series["Score"].Points.AddXY("carl",70);  
  7.     this.chart1.Series["Age"].Points.AddXY("mark",50);  
  8.     this.chart1.Series["Score"].Points.AddXY("mark",56);  
  9.     this.chart1.Series["Age"].Points.AddXY("Alli",40);  
  10.     this.chart1.Series["Score"].Points.AddXY("Alli",30);  
  11. }  
Step 3: Run

Now run your application and click on the button.
 
run your application

You can also go to my blog_munesh .


Similar Articles