基本信息
源码名称:C# winform 分页控件实例
源码大小:0.13M
文件格式:.rar
开发语言:C#
更新时间:2015-11-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

一个简单的C#分页实例


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CYQ.Data.Table;
using CYQ.Data;

namespace WinPager
{
    public partial class StartForm : Form
    {
        public StartForm()
        {
            InitializeComponent();
        }

        private void StartForm_Load(object sender, EventArgs e)
        {
            //创建文件数据库表。
            MDataTable.CreateSchema("Users.txt", false, new string[] { "UserName", "Password", "Enabled" }, SqlDbType.NVarChar, SqlDbType.NVarChar, SqlDbType.Bit);
            for (int i = 0; i < 200; i  )//插入200条数据。
            {
                using (MAction action = new MAction("Users.txt", "Txt Path={0}"))
                {
                    action.Set("UserName", "UserName_"   i);
                    action.Set("Password", "Password_"   i);
                    action.Set("Enabled", i%2==0);
                    action.Insert(InsertOp.None);
                }
            }
            pagerControl1.OnPageChanged  = new EventHandler(pagerControl1_OnPageChanged);
            LoadData();
        }

        void pagerControl1_OnPageChanged(object sender, EventArgs e)
        {
            LoadData();
        }
        void LoadData()
        {
            int count;
            using (MAction action = new MAction("Users.txt", "Txt Path={0}"))
            {
                action.Select(pagerControl1.PageIndex, pagerControl1.PageSize, string.Empty, out count).Bind(gvUsers);
                pagerControl1.DrawControl(count);
            }
        }
    }
}