1. 第一种:
    DataSet ds=new DataSet ();
    this.dataGridView1.DataSource=ds.Table[0];
  2.  
  3. 第二种:
    DataTable dt=new DataTable();
    this.dataGridView1.DataSource=dt;
  4.  
  5. 第三种:
    DataSet ds=new DataSet ();
    this.dataGridView1.DataSource = ds.Tables["表名"];
  6.  
  7. 第四种:
    DataSet ds=new DataSet ();
    this.dataGridView1.DataSource = ds;
    this.dataGridView1.DataMember = "表名";
  8.  
  9. 第五种:
    ArrayList Al = new ArrayList();
    this.dataGridView1.DataSource = Al;
  10.  
  11. 第六种:
    Dictionary<string, string> dic = new Dictionary<string, string>();
    this.dataGridView1.DataSource = dic;
  12.  
  13. 第七种:
    DataView dv = new DataView();
    this.dataGridView1.DataSource = dv;
  14.  
  15. 第八种:
    this.dataGridVi.DataSource = new BindingList<Object>(List<Object>);

Winform绑定数据源的几种方式?的更多相关文章

  1. DataGridView绑定数据源的几种方式

    使用DataGridView控件,可以显示和编辑来自多种不同类型的数据源的表格数据. 将数据绑定到DataGridView控件非常简单和直观,在大多数情况下,只需设置DataSource属性即可.在绑 ...

  2. 【转】DataGridView绑定数据源的几种方式

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

  3. Winform绑定图片的三种方式

    1.绝对路径: this.pictureBox2.Image=Image.FromFile("D:\\001.jpg"); 2.相对路径: Application.StartupP ...

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

    开始以前,先认识一下WinForm控件数据绑定的两种形式,简单数据绑定和复杂数据绑定. 1. 简单的数据绑定 例1 using (SqlConnection conn = new SqlConnect ...

  5. Android_安卓为按钮控件绑定事件的五种方式

    一.写在最前面 本次,来介绍一下安卓中为控件--Button绑定事件的五种方式. 二.具体的实现 第一种:直接绑定在Button控件上: 步骤1.在Button控件上设置android:onClick ...

  6. 为input标签绑定事件的几种方式

    为input标签绑定事件的几种方式 1.JavaScript原生态的方式,直接复制下面的代码就会有相应的效果 <!DOCTYPE html><html><head> ...

  7. MyBatis配置数据源的两种方式

    ---------------------siwuxie095                                     MyBatis 配置数据源的两种方式         1.配置方 ...

  8. angular学习笔记(三)-视图绑定数据的两种方式

    绑定数据有两种方式: <!DOCTYPE html> <html ng-app> <head> <title>2.2显示文本</title> ...

  9. JS与JQ绑定事件的几种方式.

    JS与JQ绑定事件的几种方式 JS绑定事件的三种方式 直接在DOM中进行绑定 <button onclick="alert('success')" type="bu ...

随机推荐

  1. share登录Samba可读可写(适合虚拟机下学习使用)

    直接配置 smb.conf ( path = /etc/samba/smb.conf ). 首先,进入到 samba 文件夹: cd /etc/samba/ 备份 smb.conf: mv smb.c ...

  2. Swift 2.0 异常处理

    转自:http://www.jianshu.com/p/96a7db3fde00 WWDC 2015 宣布了新的 Swift 2.0. 这次重大更新给 Swift 提供了新的异常处理方法.这篇文章会主 ...

  3. “如何稀释scroll事件”的思考(不小心写了个异步do...while)

    看了下园友的一帖子:http://www.cnblogs.com/xzhang/p/4145697.html#commentform 本来以为是很简单的问题,但仔细想想还挺有意思的.简单的说就是增加事 ...

  4. matlab 使用札记

    1.inline 命令行内置函数,作用同Function一致 2.repmat B = repmat(A,m,n)B = repmat(A,[m n])B = repmat(A,[m n p...]) ...

  5. Titanium studio安装

    在Win7 Titanium Studio的安装过程. 1.准备工作 Titanium存储空间的要求,Titanium Studio 需要1 GB.Android SDK需要1.5 GB.Blackb ...

  6. 清除缓存,计算Sql Server查询效率

    --优化之前 DBCC FREEPROCCACHE DBCC DROPCLEANBUFFERS SET STATISTICS IO ON select Dtime,Value from dbo.his ...

  7. Integer Break(Difficulty: Easy)

    题目: Given a positive integer n, break it into the sum of at least two positive integers and maximize ...

  8. 怎样用SQL语句查询一个数据库中的所有表?

    怎样用SQL语句查询一个数据库中的所有表?  --读取库中的所有表名 select name from sysobjects where xtype='u'--读取指定表的所有列名select nam ...

  9. js之事件冒泡和事件捕获详细介绍

    (1)冒泡型事件:事件按照从最特定的事件目标到最不特定的事件目标(document对象)的顺序触发. IE 5.5: div -> body -> document IE 6.0: div ...

  10. 探索javascript----事件对象下的各种X和Y

    每次用到诸如client,screen,offset等,虽然通常都是能用对的,但是总觉得不是那么的自信没错.所以整理一下可以再需要的时候来查阅. 一:clientX和clientY,screenX和s ...