In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article analyzes "how to turn pages with XtraGrid rollers" with you. The content is detailed and easy to understand. Friends who are interested in "how to turn the page with XtraGrid rollers" can follow the editor's train of thought to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "how to turn the page with XtraGrid rollers".
It is more convenient to turn the page with the wheel and drive. After some discussion and consideration, the mouse wheel page turning is finally realized in the GridView of XtraGrid.
I created a new component that inherits the original GridControl and adds an ImageList to the component to store some resource images. It is used to realize the effect of dynamic graph.
Add a custom delegate parameter and enumeration, which is used to pass paging information.
Public class PagingEventArgs: EventArgs {public int PageSize {get; set;} public int PageIndex {get; set }} public enum LoadState {/ ready / Ready, / Loading is being read, / read completed / Finish}
Add the following fields to the class of the component
/ Page size / private int_ int_page_size=20; / current page index / private int_ int_page_index=1; / Total number of records / private int_ int_record_count / read status / private LoadState _ LodaState_state
Add the following attributes
(! IsPaging) (! IsPaging) = (value >
Else
{
While (this.MainView.DataRowCount > 0)
GridView_main_view.DeleteRow (0)
This.RefreshDataSource ()
}
}} / rows per read / public int PageSize {get {if (! IsPaging) return 0; return _ int_page_size;} set {if (! IsPaging) return _ int_page_size = value;}} / Total pages / private int PageCount {get {if (RecordCount% PageSize = = 0) return RecordCount / PageSize; return RecordCount / PageSize + 1 }} / Grid / private GridView_ GridView_main_view {get {return (GridView) this.MainView;}} / whether paging is enabled / public bool IsPaging {get; set;}
Add the following delegates and events
/ private delegate void myDelegate () for internal use; / public delegate void ScrollingToPageEventHandler (object sender, PagingEventArgs e) for scrolling the page / the event of scrolling through the page / public event ScrollingToPageEventHandler OnScrollingToPage
Here are some settings for the control, which can be changed according to your preferences.
/ set the paging bar / private void InitEmbeddedNavigator () {this.EmbeddedNavigator.CustomButtons.AddRange (new DevExpress.XtraEditors.NavigatorCustomButton [] {new DevExpress.XtraEditors.NavigatorCustomButton (- 1,-1, true, false, "", null)}); this.EmbeddedNavigator.TextStringFormat = "current {1} row data"; this.UseEmbeddedNavigator = true } / set gridView / private void InitGridView () {_ GridView_main_view.TopRowChanged + = new EventHandler (gridView_TopRowChanged);}
Register the following methods for the event of the control
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 } / / check whether the bottom if (_ GridView_main_view.IsRowVisible (_ GridView_main_view.RowCount-1) = = RowVisibleState.Visible | | _ int_page_index==1) {lock (this) / / is set to start reading state {_ 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 ();}}
The TopRowChanged event is triggered when the first line of the grid changes, similar to the Scroll event of the scroll bar. Here there are two threads, the first thread for reading data and the second thread for implementing the dynamic graph. The methods called by both threads are below
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 = (= + +)
However, there is a problem with this code. When the data source bound by GridControl has children of the same instance, TopRowChanged events will be triggered continuously with the call of the RefreshData method. The exact reason is not clear. The solution to this problem is not to remove the same instance subitems on the data source, or not to call the RefreshData method.
On how to XtraGrid scroll page to share here, I hope that the above content can make you improve. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.