创建DataTable与DataGridView进行绑定
private DataTable dt = new DataTable(); BindingSource bs = new BindingSource(); ? /// <summary> //不允许自动生成,若改为允许,界面会自动增加DataTable列,那么界面上既会包含DataGridView中定义的列,也会包含DataTable定义的列 DataColumn col = new DataColumn("No",typeof(int)); bs.DataSource = dt; ? //将DataGridView中的列与DataTable中的列进行数据绑定,this.cloNum为列名 this.colNum.DataPropertyName = "No"; this.colAddress.DataPropertyName = "Addr"; this.colFunction.DataPropertyName = "FuntionType"; this.colResult.DataPropertyName = "Result"; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |