日期:2014-05-18  浏览次数:20934 次

关于DataGridView的问题
用DataGridView已经绑定数据库使用,一般,表中有几行,DGV也是几行,请 问,如果表中是10行,如何让DGV为15行,多出的五行为空就行。在最后设置rowCount错误,提示,不能在绑定的DGV控件上设置ROWCOUNT属性。
  如果不绑定,一行一行打印的就不用说了。

------解决方案--------------------
自己
C# code
dataGridView1.Rows.Add(5);

------解决方案--------------------
绑定前向DataTable中添加5个空行
------解决方案--------------------

C# code
                    DataRow dr;
                    for (int i = 0; i < 5; i++)
                    {
                        dr = yourTable.NewRow();
                        yourTable.Rows.Add(dr);
                    }                    
                    dataGridView1.DataSource = yourTable;