DataGridView中列的类型可分为DataGridViewTextBoxColumn、DataGridViewCheckBoxColumn DataGridViewImageColumn DataGridViewButtonColumn DataGridViewComboBoxColumn DataGridViewLinkColumn 自定义列类型等,在创建新列时默认该列的所有行都是一个类型,那么如何实现不同行的列类型不同可以呢?

        

  DataGridViewTextBoxCell dgvTextBoxCell = new DataGridViewTextBoxCell();
  
this.dataGridView1.Rows[dt.Rows.Count - 1].Cells["GenderID"= dgvTextBoxCell;
  dgvTextBoxCell.Value 
= "总计";

   上面代码实现的功能很简单,"GenderID"列默认类型为DataGridViewComboBoxColumn ,然后把该列最后一行改为DataGridViewTextBoxColumn类型,用于显示‘总计’两字。该思路还可以实现Combobox列不同行绑定不同的数据源

      

相关文章:

  • 2021-09-07
  • 2022-03-04
  • 2022-12-23
  • 2021-08-26
  • 2021-05-25
  • 2022-02-28
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2021-06-15
  • 2022-12-23
  • 2021-12-04
  • 2018-03-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案