DevExpress中GridControl列转义的实现方法

/// <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 "--";
}

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

时间: 2024-10-08 23:52:48

DevExpress中GridControl列转义的实现方法的相关文章

devexpress中gridcontrol 一些样式改变

改变footer为扁平化效果 整个footer背景色CustomDrawFootere.Appearance.BackColor = Color.Transparent; e.Appearance.DrawBackground(e.Graphics, e.Cache, e.Bounds); e.Handled = true; 单个列footer背景CustomDrawFooterCelle.Appearance.BackColor = Color.Lavender; e.Appearance.D

devexpress中gridcontrol头部添加垂直线(右边框)

winform开发,用devexpress中的gridcontrol控件,头部默认是3D样式,当客户希望像内容一样扁平化显示且需要添加垂直线(右边框)时恶梦开始了..经过一阵摸索发现可以这样解决: 1.设置GridControl的GridView控件的PaintStyleName属性为Web 2.为GridControl的GridView控件添加CustomDrawColumnHeader事件,参考代码如下: private void gridView1_CustomDrawColumnHead

[转]&#39;&#39;\\=DevExpress 中 汉化包 汉化方法

[DevExpress]DevExpress 中 汉化包 汉化方法 2016-02-17 21:13 1781人阅读 评论(0) 收藏 举报  分类: DevExpress(24)  版权声明:本文为博主原创文章,未经博主允许不得转载. 第一步: 在Debug 下添加 zh-CN 汉化包(自行下载) 第二步: 在 Program.cs中添加以下代码 : System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Glob

DevExpress中GridControl的属性设置

1.隐藏最上面的GroupPanel gridView1.OptionsView.ShowGroupPanel=false; 2.得到当前选定记录某字段的值 sValue=Table.Rows[gridView1.FocusedRowHandle][FieldName].ToString(); 3.数据只读 gridView1.OptionsBehavior.Editable=false; 4.不显示MasterDetailView gridView1.OptionsDetail.EnableM

DevExpress中GridControl自定义汇总列值(有选择性的汇总)

今天碰到有同事遇到这个方面的需求,贴一下吧. private void gvTop_CustomSummaryCalculate(object sender, CustomSummaryEventArgs e) { if (e.IsTotalSummary && e.SummaryProcess == CustomSummaryProcess.Finalize) { // 数据源 var data = this.gcTop.DataSource as List<StockOrderD

DevExpress实现GridControl删除所有行的方法

/// <summary> /// 删除全部行 /// </summary> /// <param name="gridView">GridView</param> public static void ClearRows(this GridView gridView) { bool _mutilSelected = gridView.OptionsSelection.MultiSelect;//获取当前是否可以多选 if (!_muti

在Pandas中更改列的数据类型【方法总结】

先看一个非常简单的例子: a = [['a', '1.2', '4.2'], ['b', '70', '0.03'], ['x', '5', '0']] df = pd.DataFrame(a) 有什么方法可以将列转换为适当的类型?例如,上面的例子,如何将列2和3转为浮点数?有没有办法将数据转换为DataFrame格式时指定类型?或者是创建DataFrame,然后通过某种方法更改每列的类型?理想情况下,希望以动态的方式做到这一点,因为可以有数百个列,明确指定哪些列是哪种类型太麻烦.可以假定每列都

Devexpress中统一设置字体样式的方法

#region 设置默认字体.日期格式.汉化dev DevExpress.Utils.AppearanceObject.DefaultFont = new System.Drawing.Font("Tahoma", 12); DevExpress.XtraEditors.WindowsFormsSettings.DefaultFont= new System.Drawing.Font("Tahoma", 12); DevExpress.XtraEditors.Win

[DevExpress]DevExpress 中 汉化包 汉化方法

第一步: 在Debug 下加入 zh-CN 汉化包(自行下载) 第二步: 在 Program.cs中加入下面代码 : System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN"); 完毕 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I