//初始化 public virtual void Initialize(BandedGridView view) { gridView = view; if (gridView == null) { return; } view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 InitGridView(); CreateGridBand(); CreateGridColumns(); view.Columns.AddRange(this.Columns); //绑定列 BindingBandColumn(); dataTable = GetDataSource(); view.EndDataUpdate(); view.EndUpdate(); }
private void BestFitBand(GridBand band) { BandedGridView view = this.advBandedGridView1; view.BeginUpdate(); string currentCaption = band.Columns[0].Caption; band.Columns[0].Caption = band.Columns[0].OwnerBand.Caption; foreach (BandedGridColumn column in band.Columns) { column.BestFit(); } band.Columns[0].Caption = currentCaption; view.EndUpdate(); }
/// <summary> /// 为BandGridView增加一个CheckBox列 /// </summary> /// <param name="view"></param> protected virtual void Attach(BandedGridView view) { if (view == null) { return; } selection.Clear(); this._view = view; view.BeginUpdate(); try { edit = view.GridControl.RepositoryItems.Add("CheckEdit") as RepositoryItemCheckEdit; column = view.Columns.Add(); column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; column.Visible = true; column.VisibleIndex = 0; column.FieldName = "CheckMarkSelection"; column.Caption = "Mark"; column.OptionsColumn.ShowCaption = false; column.OptionsColumn.AllowEdit = false; column.OptionsColumn.AllowSize = false; column.UnboundType = DevExpress.Data.UnboundColumnType.Boolean; column.Width = 80;// GetCheckBoxWidth(); column.ColumnEdit = edit; // 添加Band列,设置字体和对齐方式 GridBand band = view.Bands.AddBand("选择"); band.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; band.AppearanceHeader.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center; band.AppearanceHeader.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); view.Bands.MoveTo(0, band); view.Columns["CheckMarkSelection"].OwnerBand = band; view.Click += new EventHandler(View_Click); view.CustomDrawColumnHeader += new ColumnHeaderCustomDrawEventHandler(View_CustomDrawColumnHeader); view.CustomDrawGroupRow += new RowObjectCustomDrawEventHandler(View_CustomDrawGroupRow); view.CustomUnboundColumnData += new CustomColumnDataEventHandler(view_CustomUnboundColumnData); view.KeyDown += new KeyEventHandler(view_KeyDown); view.RowStyle += new RowStyleEventHandler(view_RowStyle); } finally { view.EndUpdate(); } }
public static Dictionary <int, GridColumn> BuildDynamicColumn <ColumnInfoType, DtoType>(BandedGridView gridView, List <ColumnInfoType> columnInfoList, List <DtoType> dtoList) where ColumnInfoType : DynamicColumnInfo where DtoType : BufferColumnDto { gridView.BeginUpdate(); gridView.GridControl.DataSource = null; ArrayList bandCollection = new ArrayList(gridView.Bands); GridBand band = null; for (int i = 0; i < bandCollection.Count; i++) { band = (GridBand)bandCollection[i]; if (band.Name.StartsWith(DynamicColumnInfo.UNIQUE_NAME_PREFIX)) { gridView.Bands.Remove(band); } } ArrayList columnCollection = new ArrayList(gridView.Columns); BandedGridColumn column = null; for (int i = 0; i < columnCollection.Count; i++) { column = (BandedGridColumn)columnCollection[i]; if (column.Name.StartsWith(DynamicColumnInfo.UNIQUE_NAME_PREFIX)) { gridView.Columns.Remove(column); } } DynamicColumnUtil.SortDynamicColumnInfo <ColumnInfoType>(columnInfoList); Dictionary <int, GridColumn> columnDic = new Dictionary <int, GridColumn>(); foreach (DynamicColumnInfo columnInfo in columnInfoList) { AddBandAndColumn(gridView, columnDic, columnInfo); } gridView.EndUpdate(); gridView.GridControl.DataSource = dtoList; return(columnDic); }
public static Dictionary <int, GridColumn> BuildDynamicColumn <ColumnInfoType>(BandedGridView gridView, List <ColumnInfoType> columnInfoList, List <DefaultDynamicColumnDto> dtoList, string rowNameCaption) where ColumnInfoType : DynamicColumnInfo { gridView.BeginUpdate(); gridView.GridControl.DataSource = null; if (gridView.Columns.ColumnByName("RowName") == null) { GridBand band = null; BandedGridColumn column = null; band = gridView.Bands.AddBand(rowNameCaption); column = gridView.Columns.Add(); column.Name = column.FieldName = "RowName"; column.Visible = true; band.Columns.Add(column); } gridView.EndUpdate(); return(BuildDynamicColumn <ColumnInfoType, DefaultDynamicColumnDto>(gridView, columnInfoList, dtoList)); }
///初始化表格 private void InitGrid() { // advBandedGridView1是表格上的默认视图,注意这里声明的是:BandedGridView BandedGridView view = advBandedGridView1 as BandedGridView; view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 view.Bands.Clear(); //修改附加选项 view.OptionsView.ShowColumnHeaders = false; //因为有Band列了,所以把ColumnHeader隐藏 view.OptionsView.ShowGroupPanel = false; //如果没必要分组,就把它去掉 view.OptionsView.EnableAppearanceEvenRow = false; //是否启用偶数行外观 view.OptionsView.EnableAppearanceOddRow = true; //是否启用奇数行外观 view.OptionsView.ShowFilterPanelMode = ShowFilterPanelMode.Never; //是否显示过滤面板 view.OptionsCustomization.AllowColumnMoving = false; //是否允许移动列 view.OptionsCustomization.AllowColumnResizing = false; //是否允许调整列宽 view.OptionsCustomization.AllowGroup = false; //是否允许分组 view.OptionsCustomization.AllowFilter = false; //是否允许过滤 view.OptionsCustomization.AllowSort = true; //是否允许排序 view.OptionsSelection.EnableAppearanceFocusedCell = true; //??? view.OptionsBehavior.Editable = false; //是否允许用户编辑单元格 view.OptionsView.ColumnAutoWidth = true; //添加列标题 GridBand bandID = view.Bands.AddBand("ID"); bandID.Visible = false; //隐藏ID列 GridBand bandName = view.Bands.AddBand("姓名"); GridBand bandSex = view.Bands.AddBand("性别"); GridBand bandBirth = view.Bands.AddBand("出生日期"); GridBand bandScore = view.Bands.AddBand("分数"); GridBand bandMath = bandScore.Children.AddBand("数学"); GridBand bandChinese = bandScore.Children.AddBand("语文"); GridBand bandEnglish = bandScore.Children.AddBand("英语"); //列标题对齐方式 bandName.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandSex.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandBirth.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandScore.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandMath.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandChinese.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandEnglish.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; ////模拟几个数据 List <Record> listDataSource = new List <Record>(); listDataSource.Add(new Record(1, "张三", "男", Convert.ToDateTime("1989-5-6"), 115.5f, 101, 96, "")); listDataSource.Add(new Record(2, "李四", "女", Convert.ToDateTime("1987-12-23"), 92, 85, 87, "")); listDataSource.Add(new Record(3, "王五", "女", Convert.ToDateTime("1990-2-11"), 88, 69, 41.5f, "")); listDataSource.Add(new Record(4, "赵六", "男", Convert.ToDateTime("1988-9-1"), 119, 108, 110, "备注行")); //////绑定数据源并显示 gridControl1.DataSource = listDataSource; gridControl1.MainView.PopulateColumns(); //将标题列和数据列对应 view.Columns["ID"].OwnerBand = bandID; view.Columns["Name"].OwnerBand = bandName; view.Columns["Sex"].OwnerBand = bandSex; view.Columns["Birth"].OwnerBand = bandBirth; view.Columns["Math"].OwnerBand = bandMath; view.Columns["Chinese"].OwnerBand = bandChinese; view.Columns["English"].OwnerBand = bandEnglish; view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 }
///初始化表格 private void InitGridData(List <QueryCafcModel> list) { // advBandedGridView1是表格上的默认视图,注意这里声明的是:BandedGridView BandedGridView view = advBandedGridView1 as BandedGridView; view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 view.Bands.Clear(); //修改附加选项 view.OptionsView.ShowColumnHeaders = false; //因为有Band列了,所以把ColumnHeader隐藏 view.OptionsView.ShowGroupPanel = false; //如果没必要分组,就把它去掉 view.OptionsView.EnableAppearanceEvenRow = false; //是否启用偶数行外观 view.OptionsView.EnableAppearanceOddRow = true; //是否启用奇数行外观 view.OptionsView.ShowFilterPanelMode = ShowFilterPanelMode.Never; //是否显示过滤面板 view.OptionsCustomization.AllowColumnMoving = false; //是否允许移动列 view.OptionsCustomization.AllowColumnResizing = false; //是否允许调整列宽 view.OptionsCustomization.AllowGroup = false; //是否允许分组 view.OptionsCustomization.AllowFilter = false; //是否允许过滤 view.OptionsCustomization.AllowSort = true; //是否允许排序 view.OptionsSelection.EnableAppearanceFocusedCell = true; //??? view.OptionsBehavior.Editable = false; //是否允许用户编辑单元格 view.OptionsView.ColumnAutoWidth = true; //添加列标题 GridBand bandID = view.Bands.AddBand("ID"); bandID.Visible = false; //隐藏ID列 GridBand bandYear = view.Bands.AddBand("年份"); GridBand bandN = view.Bands.AddBand("计入新能源核算结果"); GridBand bandN_SL = bandN.Children.AddBand("乘用车生产/进口量"); GridBand bandN_ZBZL = bandN.Children.AddBand("平均整备质量"); GridBand bandN_MBZ = bandN.Children.AddBand("目标值"); GridBand bandN_DBZ = bandN.Children.AddBand("达标值"); GridBand bandN_SJZ = bandN.Children.AddBand("实际值"); GridBand bandT = view.Bands.AddBand("不计新能源核算结果"); GridBand bandT_SL = bandT.Children.AddBand("乘用车生产/进口量"); GridBand bandT_ZBZL = bandT.Children.AddBand("平均整备质量"); GridBand bandT_MBZ = bandT.Children.AddBand("目标值"); GridBand bandT_DBZ = bandT.Children.AddBand("达标值"); GridBand bandT_SJZ = bandT.Children.AddBand("实际值"); GridBand bandS = view.Bands.AddBand("达标情况"); GridBand bandS_FLG = bandS.Children.AddBand("是否达标"); GridBand bandS_Value = bandS.Children.AddBand("实际值/达标值(%)"); GridBand bandS_Raing = bandS.Children.AddBand("排名"); #region //列标题对齐方式 bandYear.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandT.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandT_SL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandT_ZBZL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandT_MBZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandT_DBZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandT_SJZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandN.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandN_SL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandN_ZBZL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandN_MBZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandN_DBZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandN_SJZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandS.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandS_FLG.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandS_Value.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandS_Raing.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //绑定数据源并显示 gridControl1.DataSource = list; gridControl1.MainView.PopulateColumns(); #endregion //将标题列和数据列对应 view.Columns["ID"].OwnerBand = bandID; view.Columns["bandYear"].OwnerBand = bandYear; view.Columns["bandT_SL"].OwnerBand = bandT_SL; view.Columns["bandT_ZBZL"].OwnerBand = bandT_ZBZL; view.Columns["bandT_MBZ"].OwnerBand = bandT_MBZ; view.Columns["bandT_DBZ"].OwnerBand = bandT_DBZ; view.Columns["bandT_SJZ"].OwnerBand = bandT_SJZ; view.Columns["bandN_SL"].OwnerBand = bandN_SL; view.Columns["bandN_ZBZL"].OwnerBand = bandN_ZBZL; view.Columns["bandN_MBZ"].OwnerBand = bandN_MBZ; view.Columns["bandN_DBZ"].OwnerBand = bandN_DBZ; view.Columns["bandN_SJZ"].OwnerBand = bandN_SJZ; view.Columns["bandS_FLG"].OwnerBand = bandS_FLG; view.Columns["bandS_Value"].OwnerBand = bandS_Value; view.Columns["bandS_Raing"].OwnerBand = bandS_Raing; view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 }
/// <summary> /// 初始化表格 /// </summary> private void InitGrid() { BandedGridView view = CafcbandedGridView as BandedGridView; view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 view.Bands.Clear(); //修改附加选项 view.OptionsView.ShowColumnHeaders = false; //因为有Band列了,所以把ColumnHeader隐藏 view.OptionsView.ShowGroupPanel = false; //如果没必要分组,就把它去掉 view.OptionsView.EnableAppearanceEvenRow = false; //是否启用偶数行外观 view.OptionsView.EnableAppearanceOddRow = true; //是否启用奇数行外观 view.OptionsView.ShowFilterPanelMode = ShowFilterPanelMode.Never; //是否显示过滤面板 view.OptionsCustomization.AllowColumnMoving = false; //是否允许移动列 view.OptionsCustomization.AllowColumnResizing = false; //是否允许调整列宽 view.OptionsCustomization.AllowGroup = false; //是否允许分组 view.OptionsCustomization.AllowFilter = true; //是否允许过滤 view.OptionsCustomization.AllowSort = true; //是否允许排序 view.OptionsSelection.EnableAppearanceFocusedCell = true; //??? view.OptionsBehavior.Editable = false; //是否允许用户编辑单元格 view.OptionsView.ColumnAutoWidth = false; //是否显示水平滚动条 view.OptionsView.ShowFooter = true; //是否显示表底部 //view.OptionsView.AllowCellMerge = true; //添加列标题 GridBand bandJbxx = view.Bands.AddBand(""); GridBand bandNO = bandJbxx.Children.AddBand("NO"); bandNO.MinWidth = 20; GridBand bandTymc = bandJbxx.Children.AddBand("通用名称"); bandTymc.MinWidth = 60; GridBand bandPfbz = bandJbxx.Children.AddBand("排放标准"); bandPfbz.MinWidth = 60; GridBand bandClxh = bandJbxx.Children.AddBand("车辆型号"); bandClxh.MinWidth = 60; GridBand bandPl = bandJbxx.Children.AddBand("排量"); bandPl.MinWidth = 60; GridBand bandZczbzl = bandJbxx.Children.AddBand("整车整备质量"); bandZczbzl.MinWidth = 100; GridBand bandScbl = bandJbxx.Children.AddBand("生产比例"); bandScbl.MinWidth = 60; GridBand bandScl = bandJbxx.Children.AddBand("生产量"); bandScl.MinWidth = 60; GridBand bandHj = bandJbxx.Children.AddBand("合计"); bandHj.MinWidth = 60; GridBand bandDyk = bandJbxx.Children.AddBand("DYK油耗申报值(L/100km)"); bandDyk.MinWidth = 180; GridBand bandSjdbzmbz = bandJbxx.Children.AddBand("4阶段标准目标值(L/100km)"); bandSjdbzmbz.MinWidth = 200; GridBand bandDycxyhdcl = bandJbxx.Children.AddBand("单一车型油耗达成率"); bandDycxyhdcl.MinWidth = 150; GridBand bandCAFC = view.Bands.AddBand("企业平均燃料消耗量(CAFC)(L/100km)"); bandCAFC.MinWidth = 160; //bandCAFC.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; GridBand bandDykScl = bandCAFC.Children.AddBand("DYK申报值×生产量"); bandDykScl.MinWidth = 240; GridBand bandDykValues = bandCAFC.Children.AddBand("6.3109"); bandDykValues.Caption = ""; GridBand bandTCafc = view.Bands.AddBand("企业平均燃料消耗量目标值(TCAFC)(L/100km)"); bandTCafc.MinWidth = 220; //bandTCafc.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; GridBand bandTSum = bandTCafc.Children.AddBand("4阶段目标值×生产量"); bandTSum.MinWidth = 200; GridBand bandTcafcValues = bandTCafc.Children.AddBand("4.9429"); bandTcafcValues.Caption = ""; GridBand bandZczbzlAvg = view.Bands.AddBand("企业平均整备质量(kg)"); bandZczbzlAvg.MinWidth = 220; //bandZczbzlAvg.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; GridBand bandDykSum = bandZczbzlAvg.Children.AddBand("DYK申报值×生产量"); bandDykSum.MinWidth = 200; GridBand bandDykSumValue = bandZczbzlAvg.Children.AddBand("1284.714"); bandDykSumValue.Caption = ""; #region //列标题对齐方式 bandJbxx.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandNO.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTymc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandPfbz.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandClxh.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandPl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandZczbzl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandScbl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandScl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandHj.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDyk.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandSjdbzmbz.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDycxyhdcl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandCAFC.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykScl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykValues.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTCafc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTSum.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTcafcValues.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandZczbzlAvg.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykSum.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykSumValue.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 #endregion }
//初始化表格 private void InitGridCafcData() { // advBandedGridView1是表格上的默认视图,注意这里声明的是:BandedGridView BandedGridView view = CafcbandedGridView as BandedGridView; view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 view.Bands.Clear(); //修改附加选项 view.OptionsView.ShowColumnHeaders = false; //因为有Band列了,所以把ColumnHeader隐藏 view.OptionsView.ShowGroupPanel = false; //如果没必要分组,就把它去掉 view.OptionsView.EnableAppearanceEvenRow = false; //是否启用偶数行外观 view.OptionsView.EnableAppearanceOddRow = true; //是否启用奇数行外观 view.OptionsView.ShowFilterPanelMode = ShowFilterPanelMode.Never; //是否显示过滤面板 view.OptionsCustomization.AllowColumnMoving = false; //是否允许移动列 view.OptionsCustomization.AllowColumnResizing = false; //是否允许调整列宽 view.OptionsCustomization.AllowGroup = false; //是否允许分组 view.OptionsCustomization.AllowFilter = true; //是否允许过滤 view.OptionsCustomization.AllowSort = true; //是否允许排序 view.OptionsSelection.EnableAppearanceFocusedCell = true; //??? view.OptionsBehavior.Editable = false; //是否允许用户编辑单元格 view.OptionsView.ColumnAutoWidth = false; //是否显示水平滚动条 view.OptionsView.ShowFooter = true; //是否显示表底部 //view.OptionsView.AllowCellMerge = true; //添加列标题 GridBand bandJbxx = view.Bands.AddBand(""); GridBand bandNO = bandJbxx.Children.AddBand("NO"); bandNO.MinWidth = 20; GridBand bandTymc = bandJbxx.Children.AddBand("通用名称"); bandTymc.MinWidth = 60; GridBand bandPfbz = bandJbxx.Children.AddBand("排放标准"); bandPfbz.MinWidth = 60; GridBand bandClxh = bandJbxx.Children.AddBand("车辆型号"); bandClxh.MinWidth = 60; GridBand bandPl = bandJbxx.Children.AddBand("排量"); bandPl.MinWidth = 60; GridBand bandZczbzl = bandJbxx.Children.AddBand("整车整备质量"); bandZczbzl.MinWidth = 100; GridBand bandScbl = bandJbxx.Children.AddBand("生产比例"); bandScbl.MinWidth = 60; GridBand bandScl = bandJbxx.Children.AddBand("生产量"); bandScl.MinWidth = 60; GridBand bandHj = bandJbxx.Children.AddBand("合计"); bandHj.MinWidth = 60; GridBand bandDyk = bandJbxx.Children.AddBand("DYK油耗申报值(L/100km)"); bandDyk.MinWidth = 180; GridBand bandSjdbzmbz = bandJbxx.Children.AddBand("4阶段标准目标值(L/100km)"); bandSjdbzmbz.MinWidth = 200; GridBand bandDycxyhdcl = bandJbxx.Children.AddBand("单一车型油耗达成率"); bandDycxyhdcl.MinWidth = 150; GridBand bandCAFC = view.Bands.AddBand("企业平均燃料消耗量(CAFC)(L/100km)"); bandCAFC.MinWidth = 220; //bandCAFC.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; GridBand bandDykScl = bandCAFC.Children.AddBand("DYK申报值×生产量"); bandDykScl.MinWidth = 200; GridBand bandDykValues = bandCAFC.Children.AddBand("6.3109"); bandDykValues.Caption = ""; GridBand bandTCafc = view.Bands.AddBand("企业平均燃料消耗量目标值(TCAFC)(L/100km)"); bandTCafc.MinWidth = 220; //bandTCafc.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; GridBand bandTSum = bandTCafc.Children.AddBand("4阶段目标值×生产量"); bandTSum.MinWidth = 200; GridBand bandTcafcValues = bandTCafc.Children.AddBand("4.9429"); bandTcafcValues.Caption = ""; GridBand bandZczbzlAvg = view.Bands.AddBand("企业平均整备质量(kg)"); bandZczbzlAvg.MinWidth = 180; //bandZczbzlAvg.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; GridBand bandDykSum = bandZczbzlAvg.Children.AddBand("DYK申报值×生产量"); bandDykSum.MinWidth = 160; GridBand bandDykSumValue = bandZczbzlAvg.Children.AddBand("1284.714"); bandDykSumValue.Caption = ""; #region //列标题对齐方式 bandJbxx.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandNO.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTymc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandPfbz.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandClxh.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandPl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandZczbzl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandScbl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandScl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandHj.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDyk.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandSjdbzmbz.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDycxyhdcl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandCAFC.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykScl.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykValues.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTCafc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTSum.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandTcafcValues.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandZczbzlAvg.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykSum.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDykSumValue.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //绑定数据源并显示 DataTable dt = QueryCafcData(this.dtStartTime.Text, this.dtEndTime.Text, cbRllx.Text); gridControl2.DataSource = null; gridControl2.DataSource = dt; gridControl2.MainView.PopulateColumns(); #endregion #region //将标题列和数据列对应 view.Columns["NO"].OwnerBand = bandNO; view.Columns["TYMC"].OwnerBand = bandTymc; view.Columns["PFBZ"].OwnerBand = bandPfbz; view.Columns["CLXH"].OwnerBand = bandClxh; view.Columns["PL"].OwnerBand = bandPl; view.Columns["ZCZBZL"].OwnerBand = bandZczbzl; view.Columns["SCBL"].OwnerBand = bandScbl; view.Columns["SCL"].OwnerBand = bandScl; view.Columns["HJ"].OwnerBand = bandHj; //bandHj.View.CellMerge += new DevExpress.XtraGrid.Views.Grid.CellMergeEventHandler(View_CellMerge); view.Columns["ACT_ZHGKRLXHL"].OwnerBand = bandDyk; view.Columns["TGT_ZHGKRLXHL"].OwnerBand = bandSjdbzmbz; view.Columns["DYCXYHDCL"].OwnerBand = bandDycxyhdcl; view.Columns["SUM_AVGCAFC"].OwnerBand = bandDykScl; view.Columns["SUM_AVGCAFC_VALUES"].OwnerBand = bandDykValues; view.Columns["SUM_TGTCAFC"].OwnerBand = bandTSum; view.Columns["SUM_TGTCAFC_VALUES"].OwnerBand = bandTcafcValues; view.Columns["SUM_ZCZBZL"].OwnerBand = bandDykSum; view.Columns["SUM_ZCZBZL_VALUES"].OwnerBand = bandDykSumValue; //汇总信息 view.Columns["SCL"].SummaryItem.FieldName = "SCL"; view.Columns["SCL"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; view.Columns["HJ"].SummaryItem.FieldName = "HJ"; view.Columns["HJ"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; view.Columns["SUM_AVGCAFC"].SummaryItem.FieldName = "SUM_AVGCAFC"; view.Columns["SUM_AVGCAFC"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; view.Columns["SUM_TGTCAFC"].SummaryItem.FieldName = "SUM_TGTCAFC"; view.Columns["SUM_TGTCAFC"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; view.Columns["SUM_ZCZBZL"].SummaryItem.FieldName = "SUM_ZCZBZL"; view.Columns["SUM_ZCZBZL"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum; //view.Columns["A_ZCZBZL"].SummaryItem.DisplayFormat = "总数:{0}"; //view.BestFitColumns(); view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 #endregion }
private void SetGridDataProperties() { lst_datacolumnIdIndex = new List <int>(); advBandedGridView1.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False; advBandedGridView1.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.False; advBandedGridView1.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click; advBandedGridView1.OptionsBehavior.Editable = false; advBandedGridView1.OptionsMenu.EnableColumnMenu = false; advBandedGridView1.OptionsCustomization.AllowFilter = false; advBandedGridView1.OptionsView.ShowColumnHeaders = false; advBandedGridView1.OptionsView.ColumnAutoWidth = true; advBandedGridView1.IndicatorWidth = 27; advBandedGridView1.OptionsView.ShowFooter = true; ////表头及行内容居中显示 advBandedGridView1.Appearance.Row.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; advBandedGridView1.Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; BandedGridView view = advBandedGridView1 as BandedGridView; view.BeginUpdate(); view.BeginDataUpdate(); view.Bands.Clear(); BandedGridColumn columnId = new BandedGridColumn(); columnId.Caption = "ID"; columnId.Name = "gridColumn0"; columnId.OptionsColumn.AllowGroup = DevExpress.Utils.DefaultBoolean.False; columnId.OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False; columnId.OptionsColumn.AllowMove = false; columnId.OptionsEditForm.StartNewRow = true; columnId.OptionsFilter.AllowAutoFilter = false; columnId.OptionsFilter.AllowFilter = false; columnId.Visible = true; columnId.VisibleIndex = 0; columnId.Width = 40; columnId.FieldName = "TerminalID"; GridBand bandID = view.Bands.AddBand("ID"); bandID.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandID.Columns.Add(columnId); List <UniversalWayTypeEntity> lst_TypeWay_Parent = typeBll.GetConfigPointID("", TerType.UniversalTer); if (lst_TypeWay_Parent != null) { int index = 0; foreach (UniversalWayTypeEntity ParentNode in lst_TypeWay_Parent) { GridBand bandParent = view.Bands.AddBand(ParentNode.Name); bandParent.Tag = ParentNode; bandParent.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; if (ParentNode.HaveChild) //have child { List <UniversalWayTypeEntity> lst_TypeWay_Child = typeBll.Select("WHERE ParentID='" + ParentNode.ID + "' AND TerminalType='" + ((int)TerType.UniversalTer).ToString() + "' ORDER BY Sequence"); if (lst_TypeWay_Child != null) { foreach (UniversalWayTypeEntity ChildNode in lst_TypeWay_Child) { index++; GridBand bandChild = bandParent.Children.AddBand(ChildNode.Name); bandChild.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; BandedGridColumn column_child = new BandedGridColumn(); column_child.Caption = ParentNode.Name; column_child.Name = "gridColumn" + index; column_child.OptionsColumn.AllowGroup = DevExpress.Utils.DefaultBoolean.False; column_child.OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False; column_child.OptionsColumn.AllowMove = false; column_child.OptionsEditForm.StartNewRow = true; column_child.OptionsFilter.AllowAutoFilter = false; column_child.OptionsFilter.AllowFilter = false; column_child.Visible = true; column_child.VisibleIndex = index - 1; column_child.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column_child.FieldName = "column" + index; column_child.Tag = ChildNode; bandChild.Columns.Add(column_child); GridBand bandUnit = bandChild.Children.AddBand(ChildNode.Unit); bandUnit.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; if (!lst_datacolumnIdIndex.Contains(ChildNode.ID)) { lst_datacolumnIdIndex.Add(ChildNode.ID); } } } } else //alone { index++; BandedGridColumn column_parent = new BandedGridColumn(); column_parent.Caption = ParentNode.Name; column_parent.Name = "gridColumn" + index; column_parent.OptionsColumn.AllowGroup = DevExpress.Utils.DefaultBoolean.False; column_parent.OptionsColumn.AllowMerge = DevExpress.Utils.DefaultBoolean.False; column_parent.OptionsColumn.AllowMove = false; column_parent.OptionsEditForm.StartNewRow = true; column_parent.OptionsFilter.AllowAutoFilter = false; column_parent.OptionsFilter.AllowFilter = false; column_parent.Visible = true; column_parent.VisibleIndex = index - 1; column_parent.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; column_parent.FieldName = "column" + index; column_parent.Tag = ParentNode; bandParent.Columns.Add(column_parent); GridBand bandUnit = bandParent.Children.AddBand(ParentNode.Unit); bandUnit.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; if (!lst_datacolumnIdIndex.Contains(ParentNode.ID)) { lst_datacolumnIdIndex.Add(ParentNode.ID); } } } } view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 }
private void InitGrid(DataTable dt) { BandedGridView view = advBandedGridView1 as BandedGridView; //advBandedGridView1.BestFitColumns(); view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 view.Bands.Clear(); view.OptionsView.ColumnAutoWidth = true; //view.BestFitColumns(); //修改附加选项 view.OptionsView.ShowColumnHeaders = false; //因为有Band列了,所以把ColumnHeader隐藏 view.OptionsView.ShowGroupPanel = false; //如果没必要分组,就把它去掉 view.OptionsView.EnableAppearanceEvenRow = false; //是否启用偶数行外观 view.OptionsView.EnableAppearanceOddRow = true; //是否启用奇数行外观 view.OptionsView.ShowFilterPanelMode = ShowFilterPanelMode.Never; //是否显示过滤面板 view.OptionsCustomization.AllowColumnMoving = false; //是否允许移动列 view.OptionsCustomization.AllowColumnResizing = true; //是否允许调整列宽 view.OptionsCustomization.AllowGroup = false; //是否允许分组 view.OptionsCustomization.AllowFilter = true; //是否允许过滤 view.OptionsCustomization.AllowSort = true; //是否允许排序 view.OptionsSelection.EnableAppearanceFocusedCell = true; //??? // view.OptionsBehavior.Editable = false; //是否允许用户编辑单元格 view.OptionsView.ColumnAutoWidth = false; //是否显示水平滚动条 view.OptionsView.ShowFooter = false; //是否显示表底部 view.OptionsView.AllowCellMerge = true; GridBand bandCheck = view.Bands.AddBand("选择"); // bandCheck.MinWidth = 10; bandCheck.Width = 30; GridBand bandCLXH = view.Bands.AddBand("车辆型号"); bandCLXH.MinWidth = 50; GridBand bandCSLY = view.Bands.AddBand("参数来源"); bandCSLY.MinWidth = 30; //GridBand bandCPH = view.Bands.AddBand("配置号ID"); //bandCPH.MinWidth = 75; GridBand bandGGPC = view.Bands.AddBand("公告批次"); bandGGPC.MinWidth = 100; GridBand bandDCZ = view.Bands.AddBand("电池组(或超级电容)"); GridBand bandDCZDTXH = bandDCZ.Children.AddBand("单体型号"); bandDCZDTXH.MinWidth = 30; GridBand bandDCZDTSCQY = bandDCZ.Children.AddBand("单体生产企业"); bandDCZDTSCQY.MinWidth = 120; GridBand bandDCZCXXH = bandDCZ.Children.AddBand("成箱型号"); bandDCZCXXH.MinWidth = 30; GridBand bandDCZZNL = bandDCZ.Children.AddBand("电池组总能量(kWh)"); bandDCZZNL.MinWidth = 150; GridBand bandDCZSCQY = bandDCZ.Children.AddBand("电池组生产企业"); bandDCZSCQY.MinWidth = 120; GridBand bandQDDJ = view.Bands.AddBand("驱动电机"); GridBand bandQDDJXH = bandQDDJ.Children.AddBand("型号"); bandQDDJXH.MinWidth = 30; GridBand bandQDDJEDGL = bandQDDJ.Children.AddBand("额定功率(kW)"); bandQDDJEDGL.MinWidth = 100; GridBand bandQDDJSCQY = bandQDDJ.Children.AddBand("生产企业"); bandQDDJSCQY.MinWidth = 30; GridBand bandRLDC = view.Bands.AddBand("燃料电池"); GridBand bandRLDCXH = bandRLDC.Children.AddBand("型号"); bandRLDCXH.MinWidth = 30; GridBand bandRLDCEDGL = bandRLDC.Children.AddBand("额定功率(kW)"); bandRLDCEDGL.MinWidth = 100; GridBand bandRLDCSCQY = bandRLDC.Children.AddBand("生产企业"); bandRLDCSCQY.MinWidth = 30; bandCheck.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandCLXH.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandCSLY.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; //bandCPH.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandGGPC.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDCZ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDCZDTXH.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDCZDTSCQY.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDCZCXXH.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDCZZNL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandDCZSCQY.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandQDDJ.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandQDDJXH.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandQDDJEDGL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandQDDJSCQY.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandRLDC.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandRLDCXH.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandRLDCEDGL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; bandRLDCSCQY.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; dt.Columns.Add("check", System.Type.GetType("System.Boolean")); dt.Columns["check"].ReadOnly = false; for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["check"] = false; } gridControl1.DataSource = null; gridControl1.DataSource = dt; gridControl1.MainView.PopulateColumns(); view.Columns["MODEL_VEHICLE"].OptionsColumn.ReadOnly = true; view.Columns["DATASOURCE"].OptionsColumn.ReadOnly = true; view.Columns["DATASOURCE"].OptionsColumn.AllowEdit = false; //view.Columns["CONFIG_ID"].OptionsColumn.ReadOnly = true; //view.Columns["CONFIG_ID"].Visible = false; view.Columns["BATCH"].OptionsColumn.ReadOnly = true; view.Columns["MODEL_SINGLE"].OptionsColumn.ReadOnly = true; view.Columns["MFRS_SINGLE"].OptionsColumn.ReadOnly = true; view.Columns["MODEL_WHOLE"].OptionsColumn.ReadOnly = true; view.Columns["CAPACITY_BAT"].OptionsColumn.ReadOnly = true; view.Columns["MFRS_BAT"].OptionsColumn.ReadOnly = true; view.Columns["MODEL_DRIVE"].OptionsColumn.ReadOnly = true; view.Columns["RATEPOW_DRIVE"].OptionsColumn.ReadOnly = true; view.Columns["MFRS_DRIVE"].OptionsColumn.ReadOnly = true; view.Columns["MDEL_FUEL"].OptionsColumn.ReadOnly = true; view.Columns["RATEPOW_FUEL"].OptionsColumn.ReadOnly = true; view.Columns["MFRS_FUEL"].OptionsColumn.ReadOnly = true; view.Columns["check"].OwnerBand = bandCheck; view.Columns["MODEL_VEHICLE"].OwnerBand = bandCLXH; view.Columns["DATASOURCE"].OwnerBand = bandCSLY; //view.Columns["CONFIG_ID"].OwnerBand = bandCPH; //view.Columns["CONFIG_ID"].VisibleIndex = -1; view.Columns["BATCH"].OwnerBand = bandGGPC; view.Columns["MODEL_SINGLE"].OwnerBand = bandDCZDTXH; view.Columns["MFRS_SINGLE"].OwnerBand = bandDCZDTSCQY; view.Columns["MODEL_WHOLE"].OwnerBand = bandDCZCXXH; view.Columns["CAPACITY_BAT"].OwnerBand = bandDCZZNL; view.Columns["MFRS_BAT"].OwnerBand = bandDCZSCQY; view.Columns["MODEL_DRIVE"].OwnerBand = bandQDDJXH; view.Columns["RATEPOW_DRIVE"].OwnerBand = bandQDDJEDGL; view.Columns["MFRS_DRIVE"].OwnerBand = bandQDDJSCQY; view.Columns["MDEL_FUEL"].OwnerBand = bandRLDCXH; view.Columns["RATEPOW_FUEL"].OwnerBand = bandRLDCEDGL; view.Columns["MFRS_FUEL"].OwnerBand = bandRLDCSCQY; view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 /* int[] siz = new int[advBandedGridView1.Columns.Count]; * int z = 0*/ /* foreach (DevExpress.XtraGrid.Columns.GridColumn dc in advBandedGridView1.Columns) * { * dc.OptionsColumn. * }*/ }
void initGantt(List <TaskTree> tasktree, DateTime[] projectDate) { BandedGridView view = advBandedGridView1 as BandedGridView; view.BeginUpdate(); //开始视图的编辑,防止触发其他事件 view.BeginDataUpdate(); //开始数据的编辑 view.Bands.Clear(); DateTime start = new DateTime(2013, 12, 10); DateTime end = new DateTime(2014, 5, 2); GridBand gridBand = view.Bands.AddBand(start.ToString("yy-MM-dd")); gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; int days = (end - start).Days; string Day = "日一二三四五六"; CustomAxisLabel[] customaxislabels = new CustomAxisLabel[days + 1]; customaxislabels[0] = new CustomAxisLabel(start.ToString("yy-MM-dd"), start); for (int i = 0; i <= days + 1; i++) { try { CustomAxisLabel cal = new CustomAxisLabel(); cal.AxisValue = start; cal.Name = start.ToString("yy-MM-dd"); customaxislabels[i + 1] = cal; if (start.DayOfWeek == DayOfWeek.Monday) { gridBand = view.Bands.AddBand(start.ToString("yyyy-MM-dd")); gridBand.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; } GridBand childen = gridBand.Children.AddBand(Day[(int)start.DayOfWeek] + ""); childen.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; childen.Width = 24; start = start.AddDays(1); } catch { } } gcGanttDate.Width = days * 24 + 2; view.EndDataUpdate(); //结束数据的编辑 view.EndUpdate(); //结束视图的编辑 //设置甘特图属性 ccProjectGantt.Width = gcGanttDate.Width; //chartControl1.Height = 4 * 24; ganttDiagram1.AxisX.Visible = false; ganttDiagram1.AxisY.CustomLabels.AddRange(customaxislabels); ConstantLine progress = new ConstantLine("当前进度", DateTime.Now); progress.Color = Color.Red; ganttDiagram1.AxisY.ConstantLines.Add(progress); ganttDiagram1.AxisY.Range.MinValueInternal = 0; ganttDiagram1.AxisY.Range.MaxValueInternal = days * 24; ganttDiagram1.AxisY.Visible = false; series1.Points.Add(new SeriesPoint("项目进度", new DateTime[] { new DateTime(2013, 12, 12, 0, 0, 0), new DateTime(2014, 4, 30) })); SeriesPoint sp = new SeriesPoint(); series2.Points.Add(new SeriesPoint("产品进度", new DateTime[] { new DateTime(2013, 12, 12), new DateTime(2014, 1, 12) })); series2.Points.Add(new SeriesPoint("Task 2", new DateTime[] { new DateTime(2014, 1, 13), new DateTime(2014, 2, 28) })); series2.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 30) })); series2.Points.Add(new SeriesPoint("Task 4", new DateTime[] { new DateTime(2014, 4, 1), new DateTime(2014, 4, 30) })); series2.Points[2].Relations.Add(series2.Points[1]); series3.Points.Add(new SeriesPoint("产品进度", new DateTime[] { new DateTime(2013, 12, 12), new DateTime(2014, 1, 12) })); series3.Points.Add(new SeriesPoint("Task 2", new DateTime[] { new DateTime(2014, 1, 13), new DateTime(2014, 2, 28) })); series3.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 4) })); series4.Points.Add(new SeriesPoint("Task 3", new DateTime[] { new DateTime(2014, 3, 4), DateTime.Now })); }
void Invalidate() { _view.CloseEditor(); _view.BeginUpdate(); _view.EndUpdate(); }