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