Gridview Custom Appearance

Source: Internet
Author: User

Private voidForm1_Load (Objectsender, EventArgs e) {            //Chinese, need to quote Devexpress.localization.v11.2.dllDevExpress.XtraEditors.Controls.Localizer.Active =NewDevExpress.LocalizationCHS.DevExpressXtraEditorsLocalizationCHS (); DevExpress.XtraGrid.Localization.GridLocalizer.Active=NewDevExpress.LocalizationCHS.DevExpressXtraGridLocalizationCHS (); #regionLoadDataDataTable TB2=sqlcreate (); Gridcontrol1.datasource=TB2; #endregionGRIDVIEWDEV.SETDGV (GRIDVIEW1); }          PublicDataTable sqlcreate () {stringCmdtxt ="SELECT * from V_personex"; SqlConnection cn=NewSqlConnection ("server=.; database=sms; Uid=sa; Pwd="); SqlDataAdapter DAP=NewSqlDataAdapter (Cmdtxt, CN); DataSet DS=NewDataSet (); Dap. Fill (DS,"Table"); returnDs. tables[0]; }        Public voidSETDGV (DevExpress.XtraGrid.Views.Grid.GridView gridView1) {GridView1.OptionsView.ShowColumnHeader S=true;//Show Column headingsGridView1.OptionsView.ShowIndicator =false;//do not display row headingsGridView1.OptionsView.ShowGroupPanel =true;//Show Group PanelGridView1.OptionsCustomization.AllowGroup =true;//whether to allow groupingGridView1.OptionsView.ShowGroupedColumns =true;//to display grouped columnsGridView1.OptionsView.ShowFilterPanelMode = DevExpress.XtraGrid.Views.Base.ShowFilterPanelMode.Never;//whether to display the filter panelGridView1.OptionsCustomization.AllowFilter =true;//whether to allow filteringgridView1.OptionsCustomization.AllowColumnMoving=true;//whether to allow moving columnsGridView1.OptionsCustomization.AllowColumnResizing =false;//whether to allow column widths to be adjustedGridView1.OptionsCustomization.AllowSort=true;//whether to allow sortingGridView1.OptionsSelection.EnableAppearanceFocusedCell=false;//whether to allow cells to be selected//allow rows to be selected, edit not allowedGridView1.OptionsBehavior.EditorShowMode =DevExpress.Utils.EditorShowMode.Click; GridView1.OptionsBehavior.Editable=false;//whether to allow users to edit cellsGridView1.OptionsView.EnableAppearanceEvenRow=true;//whether to enable even line appearanceGridView1.OptionsView.EnableAppearanceOddRow =true;//whether to enable odd line appearanceGridView1.OptionsMenu.EnableColumnMenu =false;//Disable column header right-click menu//gridview1.clearsorting ();//Prohibit sortingGridview1.paintstylename="Flat";//set the appearance styleDevExpress.XtraGrid.Views.Grid.GridViewAppearances Appearance1 =NewDevExpress.XtraGrid.Views.Grid.GridViewAppearances (GRIDVIEW1); //Column header color: System.Drawing.Color.FromArgb (((int) (((198))), ((int) (((Byte) (232))), ((int) (((Byte) (243))) ; //Odd RowsAppearance1.EvenRow.BackColor = System.Drawing.Color.FromArgb ((int)(((byte)(236)))), ((int)(((byte)(249)))), ((int)(((byte)(254))))); Appearance1.EvenRow.Font=NewSystem.Drawing.Font ("Song Body", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //even rowsAppearance1.OddRow.BackColor =System.Drawing.Color.White; Appearance1.OddRow.Font=NewSystem.Drawing.Font ("Song Body", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); //Select RowAppearance1.FocusedRow.BackColor = System.Drawing.Color.FromArgb ((int)(((byte)(254)))), ((int)(((byte)(211)))), ((int)(((byte)( -))))); Appearance1.FocusedRow.ForeColor=System.Drawing.Color.Black; //Group Panel ColorAppearance1.GroupPanel.BackColor =System.Drawing.Color.White; Appearance1.GroupPanel.BackColor2=System.Drawing.Color.CornflowerBlue; //Group row ColorAppearance1.GroupRow.BackColor = System.Drawing.Color.FromArgb ((int)(((byte)(198)))), ((int)(((byte)(232)))), ((int)(((byte)(243))))); Appearance1.GroupRow.BackColor2= System.Drawing.Color.FromArgb ((int)(((byte)(198)))), ((int)(((byte)(232)))), ((int)(((byte)(243))))); //Blank area ColorAppearance1.Empty.BackColor =System.Drawing.Color.LightYellow; //column Header ColorAppearance1.HeaderPanel.BackColor = System.Drawing.Color.FromArgb ((int)(((byte)( About)))), ((int)(((byte)(229)))), ((int)(((byte)(249))))); //Odd RowsGridView1.Appearance.EvenRow.BackColor =Appearance1.EvenRow.BackColor; GridView1.Appearance.EvenRow.Font=Appearance1.EvenRow.Font; //even rowsGridView1.Appearance.OddRow.BackColor =Appearance1.OddRow.BackColor; GridView1.Appearance.OddRow.Font=Appearance1.OddRow.Font; //Select RowGridView1.Appearance.FocusedRow.BackColor = Appearance1.FocusedRow.BackColor;//the selected rowGridView1.Appearance.FocusedCell.BackColor = Appearance1.FocusedRow.BackColor;//Selected CellsGridView1.Appearance.FocusedRow.ForeColor = Appearance1.FocusedRow.ForeColor;//Font Color//Group Panel ColorGridView1.Appearance.GroupPanel.BackColor =Appearance1.GroupPanel.BackColor; GridView1.Appearance.GroupPanel.BackColor2=Appearance1.GroupPanel.BackColor2; //Group row ColorGridView1.Appearance.GroupRow.BackColor =Appearance1.GroupRow.BackColor; //GridView1.Appearance.GroupRow.BackColor2 = Appearance1.GroupRow.BackColor2; //Blank area ColorGridView1.Appearance.Empty.BackColor =Appearance1.Empty.BackColor; //column Header ColorGridView1.Appearance.HeaderPanel.BackColor =Appearance1.HeaderPanel.BackColor; //Set GroupingGRIDVIEW1.GROUPSUMMARY.ADD (DevExpress.Data.SummaryItemType.Count,"Group 1");//Add Group 1, if not count, the name must correspond to the field nameGridview1.groupformat ="{1} {2}";//default ' {0}: [#image]{1} {2} '; field name: Data Count =? gridview1.columns["Department Name"]. Groupindex =0;//Set default grouping columns        }         Public voidRestorelayoutfromxml (DevExpress.XtraGrid.Views.Grid.GridView GridView1,stringFilePath)    {gridView1.Appearance.RestoreLayoutFromXml (FilePath); //Load Style        }         Public voidSavelayouttoxml (DevExpress.XtraGrid.Views.Grid.GridView GridView1,stringFilePath)  {gridView1.Appearance.SaveLayoutToXml (FilePath); //Save Style}

Gridview Custom Appearance

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.