How to use the XtraGrid scroll wheel to turn pages
Wheel page turning and transmission page turning are more convenient. After some discussion and thinking, I finally implemented mouse wheel page turning in XtraGrid's GridView.
I created a new component that inherits the original GridControl, and added an ImageList to the component to store some resource images. Used to achieve the effect of dynamic graphics.
Add a custom delegate parameter and enumeration. The delegate parameter is used to transfer paging information.
public class PagingEventArgs : EventArgs { public int PageSize { get; set; } public int PageIndex { get; set; } } public enum LoadState { /// <summary> /// 就绪 /// </summary> Ready, /// <summary> /// 正在读取 /// </summary> Loading, /// <summary> /// 读取完成 /// </summary> Finish }
Add the following fields in the component class
/// <summary> /// 页面大小 /// </summary> private int _int_page_size=20; /// <summary> /// 当前页索引 /// </summary> private int _int_page_index=1; /// <summary> /// 总记录数 /// </summary> private int _int_record_count; /// <summary> /// 读取状态 /// </summary> private LoadState _LodaState_state;
Add the following properties
(!IsPaging) (!IsPaging) = (value>,
)
GridView_main_view.DeleteRow(0);
this.RefreshDataSource();
} } /// <summary> /// 每次读取的行数 /// </summary> public int PageSize { get { if (!IsPaging) return 0; return _int_page_size; } set { if (!IsPaging) return ; _int_page_size = value; } } /// <summary> /// 总页数 /// </summary> private int PageCount { get { if (RecordCount % PageSize == 0) return RecordCount / PageSize; return RecordCount / PageSize + 1; } } /// <summary> /// Grid /// </summary> private GridView _GridView_main_view { get { return (GridView)this.MainView; } } /// <summary> /// 是否启用分页 /// </summary> public bool IsPaging { get; set; }
Add the following delegates and events
/// <summary> /// 内部使用的委托 /// </summary> private delegate void myDelegate(); /// <summary> /// 滚动翻页的委托 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public delegate void ScrollingToPageEventHandler(object sender, PagingEventArgs e); /// <summary> /// 滚动翻页的事件 /// </summary> public event ScrollingToPageEventHandler OnScrollingToPage;
/// <summary> /// 设置分页栏 /// </summary> private void InitEmbeddedNavigator() {this.EmbeddedNavigator.CustomButtons.AddRange(new DevExpress.XtraEditors.NavigatorCustomButton[] { new DevExpress.XtraEditors.NavigatorCustomButton(-1, -1, true, false, "", null)}); this.EmbeddedNavigator.TextStringFormat = " 当前 {1} 行数据 "; this.UseEmbeddedNavigator = true; } /// <summary> /// 设置gridView /// </summary> private void InitGridView() { _GridView_main_view.TopRowChanged += new EventHandler(gridView_TopRowChanged); }
private void gridControl_Load(object sender, EventArgs e) { if (IsPaging) { _LodaState_state = LoadState.Ready; InitEmbeddedNavigator(); InitGridView(); } } private void gridView_TopRowChanged(object sender, EventArgs e) { lock (this) { if ( _int_page_index > PageCount || _LodaState_state != LoadState.Ready) return; } //检查是否到达底部 if (_GridView_main_view.IsRowVisible(_GridView_main_view.RowCount - 1) == RowVisibleState.Visible|| _int_page_index==1) { lock (this)//设置成开始读取状态 { _LodaState_state = LoadState.Loading; } Thread thread_load_data = new Thread(new ThreadStart(LoadData)); Thread thread_change_text = new Thread(new ThreadStart(ChangeLoadingImage)); thread_change_text.Start(); thread_load_data.Start(); } }
top_row_index = focus_index = (== (OnScrollingToPage == Exception(= = = (.Parent.Invoke( myDelegate(== (= LoadState.Finish; p_w_picpath_index = (.Parent.InvokeRequired).Parent.Invoke( myDelegate(.EmbeddedNavigator.Buttons.CustomButtons[].Visible = () ( (_LodaState_state != LoadState.Loading) (p_w_picpath_index == = ++ ( .Parent.Invoke( myDelegate(.EmbeddedNavigator.Buttons.CustomButtons[].ImageIndex = (.Parent.InvokeRequired).Parent.Invoke( myDelegate(.EmbeddedNavigator.Buttons.CustomButtons[].Visible = (= ++
The above is the detailed content of How to use the XtraGrid scroll wheel to turn pages. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

