2012-04-02 66 views
1

如果傳入值爲「Var」但無法設置,則要在Windows窗體項目的telerik radgrid上更改單元格的背景顏色。無法更改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; 
    } 
} 

注:我能夠改變前景色,但不能改變背景色。

回答

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 
相關問題