昨天写了一个做东西时,用到AdvBandedGridView,留下自已写的示例代码以做备忘。
东西很简单,只有一个属性需要注意:c1.Visible = true;
AdvBandedGridView例子
//实例化GridControl和AdvBandedGridView this.gridControl1 = new DevExpress.XtraGrid.GridControl(); this.advBandedGridView1 = new DevExpress.XtraGrid.Views.BandedGrid.AdvBandedGridView(); this.gridControl1.ViewCollection.Add(this.advBandedGridView1); this.gridControl1.Location = new System.Drawing.Point(3, 39); this.gridControl1.MainView = this.advBandedGridView1; this.gridControl1.Name = "gridControl1"; this.gridControl1.Size = new System.Drawing.Size(653, 443); this.Controls.Add(this.gridControl1); this.advBandedGridView1.GridControl = this.gridControl1; this.advBandedGridView1.Name = "advBandedGridView1"; //创建列 BandedGridColumn c1 = this.advBandedGridView1.Columns.Add(); //this.advBandedGridView1.Columns.Add(); c1.Caption = "列QQ1"; c1.Visible = true; BandedGridColumn c2 = new BandedGridColumn(); c2.Caption = "列2"; c2.Visible = true; BandedGridColumn c3 = new BandedGridColumn(); c3.Caption = "列3"; c3.Visible = true; BandedGridColumn c4 = new BandedGridColumn(); c4.Caption = "列4"; c3.Visible = true; this.advBandedGridView1.Columns.AddRange(new BandedGridColumn[] { c1, c2, c3, c4 }); //创建Band GridBand b1 = new GridBand();//this.advBandedGridView1.Bands.AddBand("MyBand1");为什么AddBand是错误的? b1.Caption = "我的1组"; GridBand b2 = new GridBand(); b2.Caption = "我的2组"; GridBand b3 = new GridBand(); b3.Caption = "我的3组"; this.advBandedGridView1.Bands.AddRange(new GridBand[] { b1, b2, b3}); //为Band添加列 b1.Columns.Add(c1); b1.Columns.Add(c2); b2.Columns.Add(c3); b2.Columns.Add(c4);