Why DataColumn.Caption doesn't work?

前端 未结 6 613
夕颜
夕颜 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:12

    I think when you bind to a DataTable, the DataGridView does not use the Caption property. It only works when you bind to a DataSet.

    You can modify the column headers manually like this:

    dataGridView.Columns[i].HeaderText = dt.Columns[i].Caption;
    

提交回复
热议问题