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