创建DataTable与DataGridView进行绑定
2021-07-14 18:13
标签:this 自动 property 界面 sum rop als tab idv private DataTable dt = new DataTable(); BindingSource bs = new BindingSource(); /// //不允许自动生成,若改为允许,界面会自动增加DataTable列,那么界面上既会包含DataGridView中定义的列,也会包含DataTable定义的列 DataColumn col = new DataColumn("No", typeof(int)); bs.DataSource = dt; //将DataGridView中的列与DataTable中的列进行数据绑定,this.cloNum为列名 this.colNum.DataPropertyName = "No"; 创建DataTable与DataGridView进行绑定 标签:this 自动 property 界面 sum rop als tab idv 原文地址:https://www.cnblogs.com/zst-blogs/p/9534220.html
/// 初始化DataTable
///
public void InitDataTable()
{
this.dataGridView1.AutoGenerateColumns = false;
dt.Columns.Add(col);
dt.Columns.Add(new DataColumn("Addr", typeof(string)));
dt.Columns.Add(new DataColumn("FuntionType", typeof(string)));
dt.Columns.Add(new DataColumn("Result", typeof(string)));
this.dataGridView1.DataSource = bs;
this.colAddress.DataPropertyName = "Addr";
this.colFunction.DataPropertyName = "FuntionType";
this.colResult.DataPropertyName = "Result";
}
文章标题:创建DataTable与DataGridView进行绑定
文章链接:http://soscw.com/essay/105208.html