Step1 :
First you need to design a table in Sql Database to retrieve the records from database.
Step2:
On the File menu, click New Project. Select Windows Forms Application as your project type.
Design the Form using controls from Toolbox.
Step3:
Now open the Form.cs page and write the following source code.
Form.CS Code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
namespace Pie_Charts_Sample
{
public partial class Form1 : Form
{
SqlHelper sql = new
SqlHelper();
public Form1()
{
InitializeComponent();
ShowPieChart();
}
private void
ShowPieChart()
{
Hashtable ht = new
Hashtable();
DataSet ds = sql.ExecuteProcudere("Student_Marks ", ht);
DataTable dt = ds.Tables[0];
PieChart.DataSource = dt;
PieChart.Series["Series1"].XValueMember
= "Name";
PieChart.Series["Series1"].YValueMembers
= "Percentage";
PieChart.DataBind();
}
}
}
Step4:
Now build the Solution and Debug it for the output.
OutPut :
I every time spent my half an hour to read this webpage's posts all the time along with a cup of coffee.
ReplyDeleteAlso visit my web site - mass texting free
Bind pie chart to database in C# Windows Forms.
ReplyDelete