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 (); }