码迷,mamicode.com
首页 > Windows程序 > 详细

C#中DataGridView控件绑定数据源有几种方式?

时间:2015-03-08 21:31:52      阅读:375      评论:0      收藏:0      [点我收藏+]

标签:

第一种:
DataSet ds=new DataSet ();
this.dataGridView1.DataSource=ds.Table[0];

第二种:
DataTable dt=new DataTable();
this.dataGridView1.DataSource=dt;

第三种:
DataSet ds=new DataSet ();
this.dataGridView1.DataSource = ds.Tables["表名"];

第四种:
DataSet ds=new DataSet ();
this.dataGridView1.DataSource = ds;
this.dataGridView1.DataMember = "表名";

第五种:
ArrayList Al = new ArrayList();
this.dataGridView1.DataSource = Al;

第六种:
Dictionary<string, string> dic = new Dictionary<string, string>();
this.dataGridView1.DataSource = dic;

第七种:
DataView dv = new DataView();
this.dataGridView1.DataSource = dv;

第八种:
this.dataGridVi.DataSource = new BindingList<Object>(List<Object>);

C#中DataGridView控件绑定数据源有几种方式?

标签:

原文地址:http://www.cnblogs.com/FLWL/p/4322290.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!