泛型绑定到DataGridView
原创
©著作权归作者所有:来自51CTO博客作者chubin518的原创作品,请联系作者获取转载授权,否则将追究法律责任
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.IO;
namespace WindowsFormsApplication12
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Bind();
}
private void Bind()
{
DataGridView dataGridView1 = new DataGridView();
dataGridView1.Dock = DockStyle.Fill;
this.Controls.Add(dataGridView1);
List<XList> fXList = new List<XList>();
fXList.Add(new XList(1, "Rol", true));
fXList.Add(new XList(2, "Chole", false));
fXList.Add(new XList(3, "John", true));
fXList.Add(new XList(4, "X.X.Y", false));
dataGridView1.DataSource = fXList;
}
}
public class XList
{
private int fId;
private string fName;
private bool fIsDeleted;
public int Id
{
get { return fId; }
set { fId = value; }
}
public string Name
{
get { return fName; }
set { fName = value; }
}
public bool IsDeleted
{
get { return fIsDeleted; }
set { fIsDeleted = value; }
}
public XList(int fId, string fName, bool fIsDeleted)
{
this.fId = fId;
this.fName = fName;
this.fIsDeleted = fIsDeleted;
}
}
}
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
STL常用泛型算法
STL常用泛型算法
STL 泛型算法 C++函数对象 STL常用算法接口 -
winform datagridview 绑定
winform datagridview 绑定
winform string class list header -
【Java 泛型】泛型用法 ( 泛型类用法 | 泛型方法用法 | 泛型通配符 ? | 泛型安全检查 )
一、泛型类用法、二、泛型方法用法、三、泛型通配符 <?>、四、泛型安全检查、
java 泛型通配符 泛型安全检查 泛型类 泛型方法 -
Java泛型:泛型类、泛型接口和泛型方法
Java泛型:泛型类、泛型接口和泛
System 泛型 泛型方法 -
java 泛型 -- 泛型类,泛型接口,泛型方法
java 泛型 -- 泛型类,泛型接口,泛型方法
泛型 泛型方法 泛型类 类型参数 可变参数