Gridcontrol Display line number, head office, print, export Excel, set header and center content method

Source: Internet
Author: User

1, generally for the table display data more intuitive, often display line number and total. Let Gridcontrol show the line number, first you need to set the width of the display line number, that is, Indicatorwith. The default value is-1, the width can be set according to the actual value, the case is set to 50, and the following code is added in the Gridview1_customdrawrowindicator event:

            // set the display line number style, center text, or set other properties according to E.info.appearance            e.info.appearance.textoptions.halignment =  DevExpress.Utils.HorzAlignment.Center;             if 0 )                1). ToString (); // Show line number}            Else                  = gridView1.RowCount.ToString (); // Total Display

In order to display better here, the line number display has been added to the center of the style, running effect:

2, set the header center, only need to set views-->appearance-->headerpanel-->textoptions.halignment=center. Content Center setting: Columns-->appearancecell-->textoptions.halignment=center. The first column sets the content centered.

3, Form printing is also the most common, printed code as follows:

Printingsystem PS =NULL; DevExpress.XtraPrinting.PrintableComponentLink Link=NULL; PS=NewDevExpress.XtraPrinting.PrintingSystem (); Link=NewDevExpress.XtraPrinting.PrintableComponentLink (PS); Ps.            Links.add (link); Link.component= GridControl1;//This can be a printable part.            string_printheader ="Print Example";//titlePageheaderfooter PHF = link. Pageheaderfooter asPageheaderfooter; PhF.            Header.Content.Clear (); PhF. Header.Content.AddRange (New string[] {"", _printheader,"" }); PhF. Header.font=NewSystem.Drawing.Font ("Song Body", -, System.Drawing.FontStyle.Bold); PhF. Header.linealignment =Brickalignment.center; Link. CreateDocument (); //Create a documentPs. Previewformex.show ();//Preview

4, Gridcontrol can also easily export Excel, the code is as follows:

" \ \ Show example. xls ");

5. Source code Download link (no points required): http://download.csdn.net/detail/kehaigang29/8863669

Gridcontrol Display line number, head office, print, export Excel, set header and center content method

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.