微软C中DataGridView控件使用方法讲义.docVIP

  • 3
  • 0
  • 约1.71万字
  • 约 18页
  • 2017-03-25 发布于湖北
  • 举报
DataGridView 动态添加新行: ? DataGridView控件在实际应用中非常实用,特别需要表格显示数据时。可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行。假如需要动态为DataGridView控件添加新行,方法有很多种,下面简单介绍如何为DataGridView控件动态添加新行的两种方法: ? 方法一: int index=this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = 1; this.dataGridView1.Rows[index].Cells[1].Value = 2; this.dataGridView1.Rows[index].Cells[2].Value = 监听; 利用dataGridView1.Rows.Add()事件为DataGridView控件增加新的行,该函数返回添加新行的索引号,即新行的行号,然后可以通过该索引号操作该行的各个单元格,如dataGridView1.Rows[index].Cells[0].Value = 1。这是很常用也是很简单的方法。 ? 方法二: DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell text

文档评论(0)

1亿VIP精品文档

相关文档