如何在Datagrid中导航页面(分页导航)

问题描述:

如何在Datagrid中导航页面(分页导航)

How to Navigate betw pages in Datagrid (Paging Navigation)

private void Previous_Click(object sender, EventArgs e)
        {
            currentPage = currentPage - 1;
            //Check if you are already at the first page.
            if ((currentPage < 1))
            {
                MessageBox.Show("You are at the First Page!");
                currentPage = 1;
                return;
            }
            else
            {
                recNo = (pageSize
                            * (currentPage - 1));
            }
            LoadPage();
        }

        private void Next_Click(object sender, EventArgs e)
        {
            if ((pageSize == 0))
            {
                MessageBox.Show("Set the Page Size, and then click the \"Fill Grid\" button!");
                return;
            }
            currentPage = (currentPage + 1);
            if ((currentPage > PageCount))
            {
                currentPage = PageCount;
                // Check if you are already at the last page.
                if ((recNo == maxRec))
                {
                    MessageBox.Show("You are at the Last Page!");
                    return;
                }
            }
            LoadPage();
        }
Note: LoadPage() Should be Defined by yourself!!