WebGrid如何为指定的行或单元格创建条件格式化

作者:控件中国网   出处:控件中国网   2015-08-20 14:34:31   阅读:7

WebGrid为开发人员提供了条件格式化功能,使用该条件格式化功能,开发人员可以创建自己的格式化信息和数据,这篇文章简要介绍如何为指定的单元格创建格式化条件,具体代码如下:

using ISNet.WebUI.WebGrid;

private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
{   
   //specific row    
   WebGridFormatCondition a = new WebGridFormatCondition();    
   a.ColumnMember = "Country";    
   a.ConditionText = "UK";    
   a.Name = "Format1";    
   a.FormatStyle.ForeColor = Color.Red;    
   a.TargetObject = ISNet.WebUI.WebGrid.TargetObjectType.Row;        

   //specific Cell    
   WebGridFormatCondition b = new WebGridFormatCondition();    
   b.ColumnMember = "City";    
   b.ConditionText = "Madrid";    
   b.Name = "Format2";    
   b.TargetColumnMember = "City";    
   b.FormatStyle.Font.Bold = true;    
   b.TargetObject = ISNet.WebUI.WebGrid.TargetObjectType.Cell;      

   WebGrid1.RootTable.FormatConditions.Add(a);    
   WebGrid1.RootTable.FormatConditions.Add(b);
}    

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat