Gridcontrol Composite header (multi-row header)

Source: Internet
Author: User

Description:

It is best to design through edit view, background coding is a bit cumbersome.

Example diagram: (The GC above is written in the background, the following is the designer design)


Background code writing:

 public void Initctrl () {DevExpress.XtraGrid.Views.BandedGrid.BandedGridView view = BGV as Devexpress.xtragri
            D.views.bandedgrid.bandedgridview; Edit view for the start view.
            BeginUpdate (); Start editing view of the data.
            Begindataupdate (); View.

            Bands.clear (); Because there are band columns, hide the column header view.

            Optionsview.showcolumnheaders = false; Column header DevExpress.XtraGrid.Views.BandedGrid.GridBand Bandid = view.            
            Bands.addband ("stu_id");
            Bandid.visible = false; DevExpress.XtraGrid.Views.BandedGrid.GridBand bandnnum = view.
            Bands.addband ("School Number"); DevExpress.XtraGrid.Views.BandedGrid.GridBand bandname = view.
            Bands.addband ("name"); The header displayed by the merged header DevExpress.XtraGrid.Views.BandedGrid.GridBand Bandsource = view.
            Bands.addband ("more Information");
            DevExpress.XtraGrid.Views.BandedGrid.GridBand bandsex = BandSource.Children.AddBand ("gender"); Devexpress.xtragrid.Views.BandedGrid.GridBand bandage = BandSource.Children.AddBand ("Age");

            DevExpress.XtraGrid.Views.BandedGrid.GridBand Bandbirth = BandSource.Children.AddBand ("Birthday"); DevExpress.XtraGrid.Views.BandedGrid.GridBand Bandadd = view.
            Bands.addband ("Address");

            Merge table header centered display bandSource.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; Whether to display the horizontal scroll bar view.
            Optionsview.columnautowidth = true; Panel value//view.

            Grouppaneltext = "Student Information"; Because there are band columns, so the ColumnHeader hidden view.
            Optionsview.showcolumnheaders = false; View.
         
            Optionsview.showgrouppanel = false;  Column bindings string[] str = new string[] {"stu_id", "Stu_number", "Stu_name", "Stu_sex", "Stu_age", "Stu_birthdate",
            "Stu_address"}; for (int i = 0; i < str. Length; i++) {DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn col = view. Columns.AddField (Str[i]); Sets the display position of the column when editing the view (second-to-last column) Col.
                Visibleindex = i; Set column format//col.
                Unboundtype = DevExpress.Data.UnboundColumnType.Decimal; This column is not editable for Col.    
                Optionscolumn.allowedit = false; Col.
                Visible = true; The column content is centered on Col.
                AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; View to add a list of views.   
            Columns.Add (COL); }//Column matches view. columns["stu_id"].
            Ownerband = Bandid; View. columns["Stu_number"].
            Ownerband = Bandnnum; View. columns["Stu_name"].
            Ownerband = Bandname; View. columns["Stu_sex"].
            Ownerband = Bandsex; View. columns["Stu_age"].
            Ownerband = bandage; View. columns["Stu_birthdate"].
            Ownerband = Bandbirth; View. columns["Stu_address"].

            Ownerband = Bandadd; Adaptive width view. BesTfitcolumns (); View.
            Enddataupdate (); View.
        EndUpdate (); }


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.