请问Visual Studio 2005(Winform)DataGridView怎么分页,有什么简单的分页方法。
我的DataGridView是 从 菜单栏的数据菜单 显示数据源  拖进去的,请教各位

解决方案 »

  1.   

    如果使用了数据源控件(ojbectDataSource,sqlDatasource...),那么不需要写什么代码,只要将GridView的AllowPaging属性设为True就可以了
      

  2.   

    我看了 没有这个属性 是Winform 不是asp.net
    我已经用VS2005的数据工具自动生成了DataGridView控件了,可是都是在一页实现的.
      

  3.   

    哦,看错了Winform的DataGridView就没有分页,要实现分页就只能自己写代码实现了用分页的存储过程,每次只取出当前一页的数据绑定到DataGridView
      

  4.   

    DataSet set1 = new DataSet("dsSource");
    DataSet set2 = new DataSet("dsTarget");
    adapter1.Fill(set1);
    adapter1.FillSchema(set2, SchemaType.Mapped);
    DataTable table1 = set1.Tables[0];
    DataTable table2 = set2.Tables[0];
    int num2 = table1.Rows.Count;
    this.intPageCount = (int) Math.Round(Math.Ceiling(((double) num2) / PAGESIZE));
    this.ViewState["PageCount"] = this.intPageCount;
    for (int num1 = 1; ((((this.intCurPageIndex - 1) * PAGESIZE) + num1) <= num2) & (num1 <= PAGESIZE); num1++)
    {
         table2.ImportRow(table1.Rows[(((this.intCurPageIndex - 1) * PAGESIZE) + num1) - 1]);
    }
    this.dgDb.DataSource = table2.DefaultView;
    this.dgDb.DataKeyField = "sender";
    this.dgDb.DataBind();