我在 Telerik,我正在尝试格式化 col 值。列索引号12
已经被赋予了一种颜色(它有效),然后我想寻找一个特定的值,如果它存在然后更改单元格颜色。如果单元格值为 4354,则更改单元格颜色....但没有任何反应。下面的代码有什么错误???
private int cellValue = 4354;
for (int i = 0; i < TelerikRadGridView.Rows.Count; i++)
{
if (TelerikRadGridView.Rows[i].Cells[i].Value == (object)cellValue)
{
e.CellElement.BackColor = Color.Gold;
}
}
这是完整的代码:
private int cellValue = 4354;
private void TelerikRadGridView_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
&& e.CellElement.ColumnIndex != 4
&& e.CellElement.ColumnIndex != 5
&& e.CellElement.ColumnIndex != 7
&& e.CellElement.ColumnIndex != 11
&& e.CellElement.ColumnIndex != 12
&& e.CellElement.ColumnIndex != 13) return;
e.CellElement.DrawFill = true;
e.CellElement.NumberOfColors = 1;
e.CellElement.BackColor = Color.LightSlateGray;
e.CellElement.GradientStyle = GradientStyles.Linear;
}
for (int i = 0; i < TelerikRadGridView.Rows.Count; i++)
{
if (TelerikRadGridView.Rows[i].Cells[i].Value == (object)cellValue)
{
e.CellElement.BackColor = Color.Gold;
}
}