C#实现数据图表

来源:互联网 发布:简单三维动画制作软件 编辑:程序博客网 时间:2024/05/21 07:00
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Data.OleDb; namespace DbChart { /// /// Form1 的摘要说明。 /// public class Form1 : System.Windows.Forms.Form { /// /// 必需的设计器变量。 /// private System.ComponentModel.Container components = null; private Bitmap MyBitmap=new Bitmap(500,500); private Graphics MyGrp= null; private int [] DbScore; private string [] DbName; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// /// 清理所有正在使用的资源。 /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// private void InitializeComponent() { // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(505, 430); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.Text = "Visual C#实现数据图表"; this.Load += new System.EventHandler(this.Form1_Load); this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); } #endregion /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.Run(new Form1()); } private void getData(string dataid,string dataName,string tableName) { try { const string dataConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=db.mdb"; OleDbConnection conn= new OleDbConnection(dataConn); conn.Open(); string sql="select * from "+tableName; OleDbCommand cmd = new OleDbCommand(sql,conn); DataSet ds = new DataSet(); OleDbDataAdapter adapter = new OleDbDataAdapter(cmd); adapter.Fill(ds); DbScore=new int[ds.Tables[0].Rows.Count]; DbName=new string[ds.Tables[0].Rows.Count]; for(int i=0;i
原创粉丝点击