C# DataGridView绑定数据源的几种常见方式

时间:2025-04-17 10:22:44

根据DataSource绑定的对象的不同,可以有一下几种简单的绑定:

// DataSet 、DataTable

// 方式1
DataSet ds=new DataSet ();
this.=[0];
this. = [“表名”];

//  方式2
DataTable dt=new DataTable();
this.=dt;

// DataView
DataView dv = new DataView();
this. = dv;

// 设置了DataMember
DataSet ds=new DataSet ();
this. = ds;
this. = “表名”;

// ArrayList
ArrayList Al = new ArrayList();
this. = Al;

// dic
Dictionary<string, string> dic = new Dictionary<string, string>();
this. = dic;

// List
= new BindingList(List);

————————————————
版权声明:本文为****博主「zgscwxd」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:/zgscwxd/article/details/85373601