winform 图标表chart

先链接数据库新建一个LinQ

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;

namespace WindowsFormsApplication16
{
    public partial class Form1 : Form
    {
        private DataClasses1DataContext Context;
        public Form1()
        {
            InitializeComponent();
            Context = new DataClasses1DataContext();

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            List<Car> list = Context.Car.Take(5).ToList();
            //为图表指定数据源
            chart1.DataSource = list;
            chart1.Series["Series1"].XValueMember = "Name";
            chart1.Series["Series1"].YValueMembers = "Oil";
            chart1.Series["Series2"].XValueMember = "Name";
            chart1.Series["Series2"].YValueMembers = "powers";
            chart1.Series["Series2"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine;
        }
    }
}

 

posted @ 2015-07-15 17:41  Yusarin  阅读(410)  评论(0编辑  收藏  举报