定义格式化的类:
public class EnableFormat : IFormatProvider, ICustomFormatter { public object GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) { return this; } else return null; } public string Format(string format, object arg, IFormatProvider formatProvider) { return arg.ToString().Equals("Y") ? "启用" : "停用"; } }
页面引用:
gridView1.Columns["EnableFlag"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom; gridView1.Columns["EnableFlag"].DisplayFormat.Format = new EnableFormat();