当程序动态为DataGridView添加一列时如果这样写:

DataGridViewColumn col = new DataGridViewColumn ();
col.Name = "colname";
col.HeaderText = "列标题";    

Dgv.Columns.Add(col);

肯定会提示“DataGridView 控件中至少有一列没有单元格模板”的错误。

怎么办呢?

将DataGridViewColumn 改成DataGridViewTextBoxColumn 或者其它ColumnType都可以。。

 

相关文章:

  • 2021-10-26
  • 2021-05-21
  • 2022-12-23
  • 2021-09-16
  • 2021-10-24
  • 2021-11-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-26
  • 2022-03-04
  • 2022-02-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案