How to add statistics and paging controls to Windows paging controls

Source: Internet
Author: User

How to add statistics and paging controls to Windows paging controls

In my blog, many Winform programs use pagination, so that you can access the data of the WCF Service in both the direct access to the database scenario and the network mode to get the data, therefore, the use of paging controls in the WInform program is a good solution. It can quickly obtain data and reduce the amount of code logic we add, implement a simple, efficient, and unified concept. This article describes how to implement data statistics in the GridControl page.

In general, the page control is displayed in two ways, one is the real page processing that requires pagination, and the other is the interface that does not need pagination, but the list and function are basically consistent, in fact, both cases further encapsulate the list control for ease of use.

Controls with the bottom bar of the page:

You do not need to pagination to maintain the control effect on the same interface.

Both methods encapsulate the GridControl control, and their usage steps and attributes are basically consistent.

The Code is as follows.

            this.winGridView1.BestFitColumnWith = false;            this.winGridView1.AppendedMenu = this.contextMenuStrip1;            this.winGridView1.gridView1.DataSourceChanged += new EventHandler(gridView1_DataSourceChanged);            this.winGridView1.OnRefresh += new EventHandler(winGridView1_OnRefresh);            this.winGridView1.gridView1.CustomColumnDisplayText += new DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventHandler(gridView1_CustomColumnDisplayText);            this.winGridView1.gridView1.RowCellStyle += new DevExpress.XtraGrid.Views.Grid.RowCellStyleEventHandler(gridView1_RowCellStyle);

 

So how can we add the statistics function on the basis of the paging control? Because the pagination control fields are automatically created based on the configuration, We need to bind the data after the creation, add it so that we can achieve statistical processing of the data. The final result we hope is to add some special values to the bottom of the statistical column, the interface is shown below. This is a case of inventory query statistics in my Winform development framework for your reference.

The preceding statistical implementation code is as follows.

/// <Summary> /// common summary /// </summary> private void CreateSummary () {GridView gridView1 = this. winGridView1.gridView1; if (gridView1! = Null & gridView1.Columns. count> 0) {gridView1.GroupSummary. clear (); gridView1.OptionsView. columnAutoWidth = false; gridView1.OptionsView. groupFooterShowMode = DevExpress. xtraGrid. views. grid. groupFooterShowMode. visibleAlways; gridView1.OptionsView. showFooter = true; gridView1.OptionsView. showGroupedColumns = true; gridView1.OptionsView. showGroupPanel = false; DevExpress. xtraGrid. columns. gridColumn IDColumn = gridView1.Columns ["ID"]; IDColumn. summary. addRange (new DevExpress. xtraGrid. gridSummaryItem [] {new DevExpress. xtraGrid. gridColumnSummaryItem (DevExpress. data. summaryItemType. count, "ID", "number of records: {0}")}); DevExpress. xtraGrid. columns. gridColumn StockQuantityColumn = gridView1.Columns ["STOCKQUANTITY"]; StockQuantityColumn. summary. addRange (new DevExpress. xtraGrid. gridSummaryItem [] {new DevExpress. xtraGrid. gridColumnSummaryItem (DevExpress. data. summaryItemType. sum, "STOCKQUANTITY", "inventory quantity: {0}")}); DevExpress. xtraGrid. columns. gridColumn StockAmountColumn = gridView1.Columns ["STOCKAMOUNT"]; StockAmountColumn. summary. addRange (new DevExpress. xtraGrid. gridSummaryItem [] {new DevExpress. xtraGrid. gridColumnSummaryItem (DevExpress. data. summaryItemType. sum, "STOCKAMOUNT", "inventory amount: {0: C2 }")});}}

This function allows us to re-call the function for statistical settings when data changes, as shown in the following code.

Private void gridview1_performancechanged (object sender, EventArgs e) {if (this. winGridView1.gridView1. columns. count> 0 & this. winGridView1.gridView1. rowCount> 0) {// set 100 width foreach (DevExpress. xtraGrid. columns. gridColumn column in this. winGridView1.gridView1. columns) {column. width = 100;} // special SetGridColumWidth ("Note", 200); SetGridColumWidth ("ItemNo", 120); SetGridColumWidth ("ItemBigType", 120 ); setGridColumWidth ("WareHouse", 120); SetGridColumWidth ("ID", 100); SetGridColumWidth ("StockQuantity", 120); SetGridColumWidth ("StockAmount", 160); // ID, stockQuantity, Unit, Price SetGridColumWidth ("Unit", 80); SetGridColumWidth ("Price", 80 );}CreateSummary ();}

The above is the statistical data effect based on the Winform paging control of DevExpress style. I hope it will help you.

 


How to Use the patnet paging Control

Functional Differences between the PatNet. PageList paging control and the AspNetPager paging Control

1. Different positioning: AspNetPager Provides paging navigation only for the Web page control and does not display data, that is to say, it is the attachment of each Web page control and serves each Web page control, while PatNet. pageList is a custom paging control, which is an independent body that is at the same level as each Web control and serves itself. It displays both the data view and paging navigation. 2. Number of features: The AspNetPager paging control only provides the single paging navigation function, PatNet. pageList Page Control for Data View display (AspNetPager is attached to the Web Control for display) the display of paging navigation and the internal encapsulation of paging algorithm Data Reading function (AspNetPager is attached to a stored procedure or is implemented by writing SQL code by yourself). From the perspective of the design concept of the object, to display a paging list, AspNetPager needs to be integrated in three aspects (Web paging control, AspNetPager, and Data Reading). This is relatively scattered and troublesome to use and has a lot of code; and PatNet. pageList paging controls are tightly and seamlessly encapsulated. Implementing a paging list is a whole, and the code of client programmers is extremely concise. 3. paging algorithm: AspNetPager is a data source provided by programmers for Web controls using stored procedures or DataAdapter objects on the client. pageList has a variety of built-in excellent paging algorithms to provide its own data sources without the programmer's concern. The lightweight Data Reading object DataReader is used. 4. cache support: No AspNetPager and the built-in slide cache mechanism is PatNet. PageList. In the case of a large amount of data, it is important that AspNetPager collects statistics on the number of records of the data table for each page feed to get a RecordCount. The PatNet. PageList paging control obtains RecordCount only when it is loaded for the first time. I have performed a test in the case of Count millions of records, it takes 10 seconds to Count it! 5. Number of controls: AspNetPager serves a variety of Web paging controls, while PatNet. pageList is an assembly that contains multiple independent paging controls (three currently) for different occasions. 6. Homepage list: AspNetPager is not supported. In Web applications, the homepage list is a non-Paging list with a small amount of data. Each list is displayed as a TOP list, friends who have done WEB have the following feelings: they are very repetitive. And PatNet. the PoorPageList page control under PageList is designed for this list, removing the burden of repeating a single record for programmers. The home page is the most visited page of a WEB site, it can be said that the performance of the home page represents the performance of the entire WEB site, so it cannot be ignored, PatNet. the PoorPageList page control under PageList can completely solve this performance problem because it has a built-in data source sliding cache mechanism, which improves the homepage reading speed by hundreds of times. 7. Page number display: The AspNetPager page number is displayed in a variety of ways, PatNet. the PageList page display method is not inferior. It also supports multiple display methods, such as number pages, previous pages, next pages (images can be used), and jump pages. 8. Change of the List data element: if the data displayed in a column of a list needs to be changed to the data displayed in other columns (for example, in the article list, pre-display: article title, author, in the AspNetPager file, you can only change it to the stored procedure or program (you need to re-compile it), but in the PatNet file. in the PageList page control, you only need to modify the aspx page (no re-compilation is required) 9. Support for multiple databases: both support multiple databases, but support different methods, aspNetPager should be written according to different databases ...... remaining full text>

The Gridview control is extended. The functions to be supported can be paging, sorting, adding, and changing. All functions can be selected.

First, you can write and sort pages by yourself using SQL statements, add and modify the pages, and select all Js statements. It is better to write by yourself, work harder, and learn more! Come on!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.