当前位置:网站首页>C# DataGridView绑定数据源的几种常见方式
C# DataGridView绑定数据源的几种常见方式
2022-07-22 10:07:00 【爱编程的小菜媛】
根据DataSource绑定的对象的不同,可以有一下几种简单的绑定:
// DataSet 、DataTable
// 方式1
DataSet ds=new DataSet ();
this.dataGridView1.DataSource=ds.Table[0];
this.dataGridView1.DataSource = ds.Tables[“表名”];
// 方式2
DataTable dt=new DataTable();
this.dataGridView1.DataSource=dt;
// DataView
DataView dv = new DataView();
this.dataGridView1.DataSource = dv;
// 设置了DataMember
DataSet ds=new DataSet ();
this.dataGridView1.DataSource = ds;
this.dataGridView1.DataMember = “表名”;
// ArrayList
ArrayList Al = new ArrayList();
this.dataGridView1.DataSource = Al;
// dic
Dictionary<string, string> dic = new Dictionary<string, string>();
this.dataGridView1.DataSource = dic;
// List
this.dataGridVi.DataSource = new BindingList(List);
————————————————
版权声明:本文为CSDN博主「zgscwxd」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zgscwxd/article/details/85373601
边栏推荐
猜你喜欢
zabbix实现钉钉监控告警
Pytest interface automated testing framework | why do you want to do the secondary development of pytest plug-ins
如何不获取root权限使用第三方主题:MIUI篇
multiple inheritance
mysql进阶(十七)Cannot Connect to Database Server问题分析
oracle怎样将字符串转为多行
管理的艺术-通过领导力驱动软件研发效能提升
How can ZABBIX customize MySQL monitoring items and trigger alarms
The luckiest geek in China: in his early twenties, he was worth more than 100 million, and retired after three startups
国产立体声音频数模D/A转换器DP4344替代兼容CS4344
随机推荐
索引为什么选择B+树
How Oracle escapes single quotation marks
干货分享-作为Lead 接手一个新的数据团队一 问题盘点 与Insights的发现
ES6新特性分享(完结)
Pytest interface automated testing framework | pytest installation and rules
发现mariadb数据库时间晚了12个小时,xxljob定时任务调度异常
Pytest interface automation test framework | pytest assertion
spinning
ATR5179单刀双掷开关芯片替代AS179-92LF
记一次 .NET 某RFID标签管理系统 CPU 暴涨分析
Oracle uses an SQL to find out which data is not in a table
Explain the adapter technology in NLP from simple to deep
「大哉数学之为用」优选法——梯级水库灌溉的优化设计
oracle用一条sql查出哪些数据不在某个表里
maxscale在mariadb主从切换后如何处理event的状态-handle_events
C # automatically generates a dictionary (when there is a lot of data)
Neo4j - cypher syntax example
Causal of maxscale_ Reads parameter
Setting proxy method in PHP curl request
世纪佳缘“大地震”