/**/ /// <summary> /// 当前页号 /// </summary> public int PageCurrent { get { return(_pageCurrent); } set { _pageCurrent = value; } } /// <summary> /// 设置页面大小 /// </summary> private void GetPageCount() { if (this.NMax > 0) { this.PageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(this.NMax) / Convert.ToDouble(this.PageSize))); lblPageCount.Text = " / " + PageCount.ToString(); lblPageCount1.Text = " ,共 " + PageCount.ToString() + " 页"; //lblPageCount1.Text = "Page no: " + PageSize.ToString() + ",Total:" + PageCount.ToString() + " pages"; } else { this.PageCount = 0; } } /// <summary> /// 控件状态初始化 /// </summary> public void init() { //清空页号的列表 cmbPagecount.Items.Clear(); this.PageCount = 1; _pageCurrent = 1; lblPageCount.Text = ""; lblcurentpage.Text = ""; lblPageCount1.Text = ""; if (toolStripComboBox1.Text == null || toolStripComboBox1.Text.Length == 0) { toolStripComboBox1.Text = _pageSize.ToString(); } } /**/ /// <summary> /// 翻页控件数据绑定的方法 关键是这步,都是调用这里 /// </summary> public void Bind() { if (this.EventPaging != null) { this.NMax = this.EventPaging(new EventPagingArg(this.PageCurrent)); } if (this.PageCurrent > this.PageCount) { this.PageCurrent = this.PageCount; } if (this.PageCount == 1) { this.PageCurrent = 1; } lblcurentpage.Text = PageCurrent.ToString(); lblRecordCount.Text = "共有 " + NMax.ToString() + " 条记录"; //lblRecordCount.Text = "Total: " + NMax.ToString() + " records"; btnPrev.Enabled = true; btnFirst.Enabled = true; btnLast.Enabled = true; btnNext.Enabled = true; if (this.PageCurrent == 1) { this.btnPrev.Enabled = false; this.btnFirst.Enabled = false; } if (this.PageCurrent == this.PageCount) { this.btnLast.Enabled = false; this.btnNext.Enabled = false; } if (this.NMax == 0) { btnNext.Enabled = false; btnLast.Enabled = false; btnFirst.Enabled = false; btnPrev.Enabled = false; } if (cmbPagecount.Items.Count == 0) { cmbPagecount.Items.Clear(); for (int i = 1; i <= PageCount; i++) { cmbPagecount.Items.Add(i.ToString()); } } cmbPagecount.SelectedIndex = PageCurrent - 1; }
/// <summary> /// 计算总页数 /// </summary> public void GetPageCount() { if (NMax > 0) { PageCount = int.Parse(Math.Ceiling(double.Parse(NMax.ToString()) / double.Parse(PageSize.ToString())).ToString()); } else { PageCount = 0; } }