我想更改 RadGrid Telerik 中列的颜色。我想给 to 一个颜色col index 2,3
和不同的颜色 to col Index 0,1
。
col 2,3 的颜色有效,但Col index 0,1 is not working,
索引中没有颜色Col index 0 & 1
这是代码:
bool dontRunHandler;
private void datagridview_CellFormatting(object sender, CellFormattingEventArgs e)
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
if (dontRunHandler == false)
{
if (e.CellElement.ColumnIndex != 2 && e.CellElement.ColumnIndex != 3 ) return;
e.CellElement.DrawFill = true;
e.CellElement.NumberOfColors = 1;
e.CellElement.BackColor = Color.LightSlateGray;
e.CellElement.GradientStyle = GradientStyles.Linear;
}
else
{
if (e.CellElement.ColumnIndex != 0 && e.CellElement.ColumnIndex != 1 ) return;
e.CellElement.DrawFill = true;
e.CellElement.NumberOfColors = 1;
e.CellElement.BackColor = Color.MediumVioletRed;
e.CellElement.GradientStyle = GradientStyles.Linear;
}
}