如果传入的值为“Var”但无法设置,则我想在Windows窗体项目的telerik radgrid上更改单元格的背景颜色。
private void radGridView1_DataBindingComplete(object sender, Telerik.WinControls.UI.GridViewBindingCompleteEventArgs e)
{
for (int i = 0; i < radGridView1.RowCount; i++)
{
string ImageStatusButton = radGridView1.Rows[i].Cells[7].Value.ToString();
if (ImageStatusButton == "Var")
radGridView1.Rows[i].Cells[7].Style.BackColor = Color.Red;
}
}
注意:我可以更改前景但无法更改背景颜色。
答案 0 :(得分:2)
尝试消化下面的代码。它有效!
Dim colIndex = FloorZoningGridView.Columns("colSizeInPercent").Index
Dim cellPlaceHolder As Telerik.WinControls.UI.GridCellElement
If currentFloorZoningProperty.GetFloorZoningTotalSizePercent <> 100 Then
For Each row In FloorZoningGridView.Rows
cellPlaceHolder = FloorZoningGridView.TableElement.GetCellElement(row, FloorZoningGridView.Columns(colIndex))
cellPlaceHolder.DrawFill = True
cellPlaceHolder.BackColor = Drawing.Color.Pink
Next
Else
For Each row In FloorZoningGridView.Rows
cellPlaceHolder = FloorZoningGridView.TableElement.GetCellElement(row, FloorZoningGridView.Columns(colIndex))
cellPlaceHolder.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local)
cellPlaceHolder.ResetValue(VisualElement.BackColorProperty, ValueResetFlags.Local)
Next
End If