Why DataColumn.Caption doesn't work?

前端 未结 6 608
夕颜
夕颜 2020-12-10 12:28

I am trying to create a DataTable and bind it to a DataGridView. It works, but I can\'t set columns headers via the Caption property.

6条回答
  •  粉色の甜心
    2020-12-10 13:05

    @aquinas, this works for me

    foreach (DataGridViewColumn col in dataGridView1.Columns) {
      col.HeaderText = dt.Columns[col.Name].Caption;
    }
    

提交回复
热议问题