Lightswitch C1FLexGrid 自定义列显示格式的几种写法
来源:互联网 发布:吉林大学网络平台登陆 编辑:程序博客网 时间:2024/06/01 10:18
1.最简单的方式,在控件列属性里设置,注(列的控件类型必需设为FLEX自带的那种才行), 有FORMAT CONDITION 可以设置,包括色彩等。一列只能定义一种规则。
2. 实现CellFactory ,自定义规则
public class ConditionalCellFactory : CellFactory
{
public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange rng, System.Windows.Controls.Border bdr)
{
base.ApplyCellStyles(grid, cellType, rng, bdr);
if ((cellType == CellType.Cell) && (rng.Column == 13)) // 对第几列处理
{
var row = grid.Rows[rng.Row];
var cst = row.DataItem as OrderDetailExecuteDataItem; //获取当前行的实际对象值转一下
if (cst != null)
{
if (cst.DeliveryDate.Date > DateTime.Today)
bdr.Background = new SolidColorBrush(Colors.Blue);
else
bdr.Background = new SolidColorBrush(Colors.Red);
}
}
}
}
partial void FlexibleOrderDetailExecuteDataBySupplierIDGrid_Created()
{
IContentItemProxy proxy = this.FindControl("C1FlexGrid");
proxy.ControlAvailable += (s, e) =>
{
var fg = e.Control as C1FlexGrid;
if (fg != null)
{
fg.CellFactory = new ConditionalCellFactory();
}
};
}
3. 直接调用现有条件格式类(和第一个本质是一样,只是后台用代码实现,但可以定义多个规则)
void proxy_ControlAvailable(object sender, ControlAvailableEventArgs e)
{
C1.Silverlight.FlexGrid.C1FlexGrid _flex =
e.Control as C1.Silverlight.FlexGrid.C1FlexGrid;
LSColumn col = _flex.Columns["Country"] asLSColumn;
TextConditionalFormat f1 = newTextConditionalFormat(Colors.Red, Colors.White, false);
f1.Operator = ConditionOperator.Equals;
f1.Value = "Canada";
TextConditionalFormat f2 = newTextConditionalFormat(Colors.Blue, Colors.White, false);
f2.Operator = ConditionOperator.Equals;
f2.Value = "USA";
TextConditionalFormat f3 = newTextConditionalFormat(Colors.Green, Colors.White, false);
f3.Operator = ConditionOperator.Equals;
f3.Value = "Mexico";
col.ConditionalFormats.Add(f1);
col.ConditionalFormats.Add(f2);
col.ConditionalFormats.Add(f3);
}
或者自己实现一个条件类:
public class CustomFormat : C1.LightSwitch.FlexGrid.Presentation.Controls.NumericConditionalFormat
{
public CustomFormat(string backColor) : base(backColor, null, false)
{
}
public override bool IsValid
{
get { return true; }
}
public override bool Evaluate(object obj)
{
if (IsNumeric(obj))
{
decimal n = System.Convert.ToDecimal(obj);
return (n % 5M) == 0;
}
return false;
}
}
- Lightswitch C1FLexGrid 自定义列显示格式的几种写法
- lightswitch C1FlexGrid 分组列头自定义标题处理
- DataProvider几种格式的写法
- Flex dataprovider的几种格式写法
- 几种特殊时间格式的写法
- 自定义Mapper文件的几种写法
- 自定义View的几种写法一
- checkedComboBoxEdit与C1FlexGrid列的同步
- DateTime.ToString()的几种显示格式
- Oracle 自定义type的几种写法(转载--备份)
- C1FlexGrid的某一列数据太长了,进行换行操作
- 设置dagagridView某列的显示格式
- GridControl中列的显示格式设置
- 自定义lightswitch主屏幕
- JSP页显示当前几种格式的日期方法!
- jsp显示当前时间的几种格式!
- Bigcommerce系统网站显示日期的几种格式
- 爱的几种写法
- unix网络编程卷一: 从服务器获取时间信息(一)
- 提示The import XXX cannot be resolved
- 关于函数指针
- 日经社説 20150424 ドローン生かすためにも悪用の道ふさげ
- js操作JOSN对象和字符串
- Lightswitch C1FLexGrid 自定义列显示格式的几种写法
- C函数指针学习
- VC++ List Control 的具体用法实例。
- 页面内定义的js变量,如何在引入的JS文件中使用
- 05-树6. Path in a Heap (25)
- 用CSS美化你的滚动条
- hadoop1.0 和hadoop2.0 任务处理架构比较
- QQ中的相关文件功能
- Java学习之4种方法遍历Map集合