0
我有一個PivotDataGrid,它工作正常。還添加了一個CustomUnboundFieldData,但現在我想根據此字段中的值更改單元格的背景顏色。C#更改CustomFieldData事件的背景顏色
要更改顏色我使用customCellAppearance事件。在我處理未綁定字段數據中的值後,只有這個事件被觸發。
所以我的問題基本上是,如何改變一個單元格的背景。使用未綁定的字段數據事件?
下面的代碼
//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;
}
}
和你的代碼行負責改變顏色? – 2011-12-28 15:19:32
函數「Control_CustomCellAppearance」負責。我剛剛添加了這個功能。 – Rolf 2011-12-29 08:16:40