void HandlePage(int newPage) { if (this.AllowPaging) { DataGridViewPageEventArgs e = new DataGridViewPageEventArgs(newPage); this.OnPageIndexChanging(e); if (!e.Cancel) { if (e.NewPageIndex <= -1) return; if ((e.NewPageIndex >= this.PageCount) && (this.PageIndex == this.PageCount - 1)) return; this.PageIndex = e.NewPageIndex; this.OnPageIndexChanged(EventArgs.Empty); this.RequiresDataBinding = true; } } }
/// <summary> /// 触发<see cref="PageIndexChanging"/>事件。 /// </summary> /// <param name="e"></param> protected virtual void OnPageIndexChanging(DataGridViewPageEventArgs e) { DataGridViewPageEventHandler handler = this.PageIndexChanging; if (handler != null) handler(this, e); }