SetThemeValueOverride is not available, though I did try SetDefaultValueOverride. It sort of works, but when selecting a row with an altered backcolor and then selecting a different row, the first row that was selected continues to show as selected (blue) until scrolled out of view. Scrolling it back into view then shows the proper color. Also, the alternating row color (gray) is randomly placed instead of every other row (not including rows with altered backcolors.
Here is my RowFormatting event handler;
private void grdWeekendAssistance_RowFormatting(object sender, RowFormattingEventArgs e)
{
if (!e.RowElement.RowInfo.IsSelected)
{
if ((int)e.RowElement.RowInfo.Cells["RelationshipFlag"].Value == 1)
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = GradientStyles.Solid;
//e.RowElement.BackColor = Color.Red;
e.RowElement.SetDefaultValueOverride(VisualElement.BackColorProperty, Color.Red);
}
else if ((int)e.RowElement.RowInfo.Cells["LimitedAdvocacyFlag"].Value == 1)
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = GradientStyles.Solid;
//e.RowElement.BackColor = Color.Orange;
e.RowElement.SetDefaultValueOverride(VisualElement.BackColorProperty, Color.Orange);
}
else if ((int)e.RowElement.RowInfo.Cells["AssociateLanguageID"].Value == (int)Common.Lib.Language.Spanish)
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = GradientStyles.Solid;
//e.RowElement.BackColor = Color.Green;
e.RowElement.SetDefaultValueOverride(VisualElement.BackColorProperty, Color.Green);
}
else if ((int)e.RowElement.RowInfo.Cells["CampaignSubTypeID"].Value != (int)Common.Lib.CampaignSubtype.WeekendAssignment &&
(int)e.RowElement.RowInfo.Cells["CampaignSubTypeID"].Value != (int)Common.Lib.CampaignSubtype.Salesians &&
(int)e.RowElement.RowInfo.Cells["CampaignSubTypeID"].Value != (int)Common.Lib.CampaignSubtype.PreciousBlood)
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = GradientStyles.Solid;
//e.RowElement.BackColor = Color.LightBlue;
e.RowElement.SetDefaultValueOverride(VisualElement.BackColorProperty, Color.LightBlue);
}
else if (e.RowElement.RowInfo.Cells["AssociateState"].Value.ToString() != e.RowElement.RowInfo.Cells["HLState"].Value.ToString())
{
e.RowElement.DrawFill = true;
e.RowElement.GradientStyle = GradientStyles.Solid;
//e.RowElement.BackColor = Color.Yellow;
e.RowElement.SetDefaultValueOverride(VisualElement.BackColorProperty, Color.Yellow);
}
else
{
//if (e.RowElement.IsOdd && !e.RowElement.IsSelected)
//{
// e.RowElement.DrawFill = true;
// e.RowElement.GradientStyle = GradientStyles.Solid;
// e.RowElement.BackColor = Color.Gainsboro;
//}
//else
//{
e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
//e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.RowElement.ResetStyleSettings(true, null);
//}
}
}
}