datagridview 代碼添加列
阿新 • • 發佈:2018-10-12
方式 int key urn sha 流水號 str sts per
int column_key = 0; private DataGridViewTextBoxColumn column_add(string name) { DataGridViewTextBoxColumn txtClum = new DataGridViewTextBoxColumn(); txtClum.DataPropertyName = "txt" + column_key++.ToString(); txtClum.Name = "txt" + column_key++.ToString() ; txtClum.HeaderText = name; return txtClum; }
//調用column_add添加列
dgvCostSum.Columns.Add(column_add("日期")); dgvCostSum.Columns.Add(column_add("姓名/單位")); dgvCostSum.Columns.Add(column_add("流水號")); dgvCostSum.Columns.Add(column_add("體檢金額")); dgvCostSum.Columns.Add(column_add("收費員")); dgvCostSum.Columns.Add(column_add("支付方式"));
datagridview 代碼添加列