_gridView = new DevExpress.XtraGrid.Views.Grid.GridView[_dataSet.Tables.Count];
            for (int i = 0; i < _dataSet.Tables.Count; i++)
            {
                _columns = new DevExpress.XtraGrid.Columns.GridColumn[_dataSet.Tables[i].Columns.Count];
                _gridView[i] = new DevExpress.XtraGrid.Views.Grid.GridView();
                //
                // _gridView[i]
                //
                this._gridView[i].GridControl = this.gcLongNoGive;
                this._gridView[i].Name = _dataSet.Tables[i].TableName;
                if (i == 0)
                    this.gcLongNoGive.MainView = _gridView[i];
                this.gcLongNoGive.ViewCollection.Add(this._gridView[i]);                this._gridView[i].OptionsView.ShowFooter = true;
                this._gridView[i].OptionsView.ShowHorzLines = true;
                this._gridView[i].OptionsView.ColumnAutoWidth = false;
                this._gridView[i].Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                this._gridView[i].Appearance.HeaderPanel.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                //交替显示背景色
                this._gridView[i].OptionsPrint.EnableAppearanceEvenRow = true;
                this._gridView[i].OptionsPrint.EnableAppearanceOddRow = true;
                this._gridView[i].RefreshData();                for (int j = 0; j < _dataSet.Tables[i].Columns.Count; j++)
                {
                    _columns[j] = new DevExpress.XtraGrid.Columns.GridColumn();
                    _columns[j].Caption = _dataSet.Tables[i].Columns[j].Caption;
                    _columns[j].FieldName = _dataSet.Tables[i].Columns[j].ColumnName;
                    _columns[j].Name = _dataSet.Tables[i].Columns[j].ColumnName;
                    _columns[j].Visible = true;
                    _columns[j].VisibleIndex = j;                }
                loadGridAttribute(_columns);
                
                this._gridView[i].Columns.AddRange(_columns);
                
            }
            //
            //gridControl
            //
            this.gcLongNoGive.DataSource = _dataSet;
            this.gcLongNoGive.MainView.PopulateColumns();很不明白,为什么view不能加入多个,必须要用AdvBandedGridView来实现嘛?还有,为什么背景交替显示出不生效?请牛人指教,谢谢!

解决方案 »

  1.   

    如果从交替显示看,DataGridView实现的很好
      

  2.   

    view可以加入多个的。还可以定义多个View之间的关系。
    交替显示设置一下就OK了。
      

  3.   

    this.gridControl1.ViewCollection.Add(_gridView[i]);
    girdView定义了,但没有加到gridControl中。
      

  4.   


    怎样设置?
    //交替显示背景色 
                    this._gridView[i].OptionsPrint.EnableAppearanceEvenRow = true; 
                    this._gridView[i].OptionsPrint.EnableAppearanceOddRow = true; 
    不对?
    能否给段代码?
      

  5.   

    以前用过spread应该是先都 初始好列然后再循环负值