分享

泛型List<T>作为DataGriView数据源

 昵称10504424 2013-02-20
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5.   
  6. namespace STUDENT  
  7. {  
  8.     class Student  
  9.     {  
  10.         int id;  
  11.   
  12.         public int Id  
  13.         {  
  14.             get { return id; }  
  15.             set { id = value; }  
  16.         }  
  17.         string name;  
  18.   
  19.         public string Name  
  20.         {  
  21.             get { return name; }  
  22.             set { name = value; }  
  23.         }  
  24.         int age;  
  25.   
  26.         public int Age  
  27.         {  
  28.             get { return age; }  
  29.             set { age = value; }  
  30.         }  
  31.         string sex;  
  32.   
  33.         public string Sex  
  34.         {  
  35.             get { return sex; }  
  36.             set { sex = value; }  
  37.         }  
  38.         public Student(int id, string name, int age, string sex)  
  39.         {  
  40.             this.Id = id;  
  41.             this.Name = name;  
  42.             this.Age = age;  
  43.             this.Sex = sex;  
  44.         }  
  45.     }  
  46. }  


对控件DataGridView1绑定:

如果通过TextBox 输入来查询:


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多