码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress中GridControl列转义的实现方法

时间:2017-09-20 00:40:45      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:void   color   led灯   column   ndis   ==   ati   grid   end   

 

/// <summary>
/// CustomColumnDisplayText Helper
/// </summary>
/// <param name="girdview">GridView</param>
/// <param name="fieldNameHandler">委托</param>
/// <param name="dispalyTextHandler">展现文字</param>
/// <param name="e">CustomColumnDisplayTextEventArgs</param>
public static void CusColDisplayTextHelper(this GridView girdview, Predicate<string> fieldNameHandler, Func<object, string> dispalyTextHandler, CustomColumnDisplayTextEventArgs e)
{
  if (fieldNameHandler(e.Column.FieldName))
  {
 e.DisplayText = dispalyTextHandler(e.Value);
  }
}
/// <summary>
/// CustomColumnDisplayText Helper
/// </summary>
/// <param name="girdview">GridView</param>
/// <param name="valueHandler">委托</param>
/// <param name="dispalyTextHandler">委托</param>
/// <param name="e">CustomColumnDisplayTextEventArgs</param>
public static void CusColDisplayTextHelper(this GridView girdview, Func<object, Type, bool> valueHandler, Func<object, string> dispalyTextHandler, CustomColumnDisplayTextEventArgs e)
{
  if (valueHandler(e.Value, e.Value.GetType()))
  {
 e.DisplayText = dispalyTextHandler(e.Value);
  }
}
/// <summary>
///CustomColumnDisplayText Helper
/// </summary>
/// <param name="girdview">GridView</param>
/// <param name="valueHandler">委托</param>
/// <param name="curdispalyText">展现文字</param>
/// <param name="e">CustomColumnDisplayTextEventArgs</param>
public static void CusColDisplayTextHelper(this GridView girdview, Func<object, Type, bool> valueHandler, string curdispalyText, CustomColumnDisplayTextEventArgs e)
{
  if (valueHandler(e.Value, e.Value.GetType()))
  {
 e.DisplayText = curdispalyText;
  }
}
private void gvLampConfig_CustomColumnDisplayText(object sender, CustomColumnDisplayTextEventArgs e)
{
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("LampViDirection"), value => value.ToInt(1) == 1 ? "正向" : "反向", e);
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("LampWorkStatus"), TranLampWorkType, e);
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("CTUChNo"), value => string.Format("第{0}回路", value), e);
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("LampPhase"), TranLampPhase, e);
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("LampDeviceType"), TranLampDeviceType, e);
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("LampPower"), value => string.Format("{0} W", value), e);
  gvLampConfig.CusColDisplayTextHelper(name => name.Equals("LampIntensity"), value => string.Format("{0} %", value), e);
  gvLampConfig.CusColDisplayTextHelper((value, type) => value.ToInt(-1) == -1 && type == typeof(Int32), "不修改", e);
}
private string TranLampDeviceType(object type)
{
  int _type = type.ToInt(-1);
  if (_type == 1) return "钠灯";
  if (_type == 2) return "LED灯";
  if (_type == 3) return "无极灯";
  return "--";
}
private string TranLampPhase(object type)
{
  int _type = type.ToInt(-1);
  if (_type == 0) return "未知";
  if (_type == 1) return "A相";
  if (_type == 2) return "B相";
  if (_type == 3) return "C相";
  return "--";
}
private string TranLampWorkType(object type)
{
  int _type = type.ToInt(-1);
  if (_type == 0) return "关闭但不删除";
  if (_type == 1) return "启用";
  if (_type == 2) return "删除";
  return "--";
}

技术分享

 

DevExpress中GridControl列转义的实现方法

https://ctolib.com/topics-51143.html

DevExpress中GridControl列转义的实现方法

标签:void   color   led灯   column   ndis   ==   ati   grid   end   

原文地址:http://www.cnblogs.com/shy1766IT/p/7554776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!