datagridview 绑定 datatable
2020-12-13 03:57
标签:datagridview for new res table ar if (dt != null) } datagridview 绑定 datatable,搜素材,soscw.com datagridview 绑定 datatable 标签:datagridview for new res table ar 原文地址:http://www.cnblogs.com/xiguanjiandan/p/3824513.html
{
DataGridViewColumn dgvc = null;
this.dataGridView1.DataSource = null;
this.dataGridView1.Columns.Clear();
foreach (DataColumn dc in dt.Columns)
{
dgvc = new DataGridViewColumn();
dgvc.Name = dc.ColumnName;
dgvc.HeaderText = dc.ColumnName;
dgvc.DataPropertyName = dc.ColumnName;
dgvc.CellTemplate = new DataGridViewTextBoxCell();
dgvc.Resizable = DataGridViewTriState.True;
dgvc.SortMode = DataGridViewColumnSortMode.Automatic;
this.dataGridView1.Columns.Add(dgvc);
}
this.dataGridView1.AutoGenerateColumns = false;
this.dataGridView1.DataSource = dt;
下一篇:Spring