本文介绍了如何在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!!


这篇关于如何在Datagrid中导航页面(分页导航)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 14:01
查看更多