GridControl的列DisplayFormat自定义方法


定义格式化的类:

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();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM