RepositoryItemTextEdit repositoryItemTextEdit1 = new RepositoryItemTextEdit(); repositoryItemTextEdit1.Mask.EditMask = "\d{0,}\.[0,5]|\d{0,}"; repositoryItemTextEdit1.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.RegEx; gcDeatil.BeginUpdate();//明细 for (int i = 0; i < dt.Columns.Count ; i++) { GridColumn col = new GridColumn(); bool exists = ((IList)ewNotVisiblecolumns).Contains(dt.Columns[i].ColumnName); if (exists == true || dt.Columns[i].ColumnName == "ID") continue; col.Name = "col" + dt.Columns[i].ColumnName; col.FieldName = dt.Columns[i].ColumnName; col.Caption = dt.Columns[i].ColumnName; col.DisplayFormat.FormatString = "#0.#"; col.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; col.ColumnEdit = repositoryItemTextEdit1; col.OptionsFilter.AllowAutoFilter = false; col.Width = 45; col.Visible = true; //设置合计数 if (((IList) sumcolumns).Contains(dt.Columns[i].ColumnName) == true) { col.Summary.AddRange(new DevExpress.XtraGrid.GridSummaryItem[] { new DevExpress.XtraGrid.GridColumnSummaryItem(DevExpress.Data.SummaryItemType.Sum)}); } col.AppearanceHeader.BackColor = Color.SkyBlue; col.AppearanceHeader.BackColor2 = Color.SkyBlue; if (dt.Columns[i].ColumnName == "Sph") { col.OptionsColumn.AllowEdit = false ; col.OptionsColumn.ReadOnly = false; col.AppearanceCell.ForeColor = Color.MediumOrchid; col.AppearanceCell.BackColor = Color.LightSeaGreen; col.OptionsColumn.AllowFocus = false; col.AppearanceCell.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold); //col.Width = 50; col.OptionsColumn.AllowSize = false; } gv.Columns.Add(col); }