【发布时间】:2011-12-28 15:00:35
【问题描述】:
我有一个工作正常的 PivotDataGrid。还添加了一个CustomUnboundFieldData,但现在我想根据该字段中的值更改单元格的背景颜色。
要更改颜色,我使用 customCellAppearance 事件。只有在我操作未绑定字段数据中的值后才会触发此事件。
所以我的问题基本上是,如何更改单元格的背景。使用未绑定的字段数据事件?
在代码的 sn-p 下方
//create unbound field
PivotGridField unboundField = pivot.Control.Fields.Add("unboundDataField", FieldArea.FilterArea);
unboundField.UnboundType = FieldUnboundColumnType.String;
//fill unbound field with data
private void Control_CustomUnboundFieldData(object sender, PivotCustomFieldDataEventArgs e)
{
String myValue = Convert.ToString(e.GetListSourceColumnValue("sourceColumn"));
e.Value = myValue.Substring(6);
e.Field.SummaryType = FieldSummaryType.Max;
}
//code to change appearance of different cells
private void Control_CustomCellAppearance(object sender, PivotCustomCellAppearanceEventArgs e)
{
if(e.Value != null)
{
e.Background = System.Windows.Media.Brushes.Green;
}
}
【问题讨论】:
-
你的哪一行代码负责改变颜色?
-
函数“Control_CustomCellAppearance”对此负责。我刚刚添加了这个功能。
标签: c# wpf devexpress