2014-05-09 25 views
0

我有一个简单的RadGridView,在第一个单元格内我有Checkbox其中我想更改我的行的颜色,如果此Checkbox处于选中状态并返回到原始颜色if此Checkbox处于未选中状态。RadGridView更改单元格后的行颜色CheckBox选中/取消选中

目前这是我尝试和这画我的行时,我的Checkbox检查,但我如何更改为原始颜色时,我的Checkbox未选中?

 private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) 
    { 
     if ((bool)e.RowElement.RowInfo.Cells["Select"].Value == true) 
     { 
      e.RowElement.DrawFill = true; 
      e.RowElement.GradientStyle = GradientStyles.Solid; 
      e.RowElement.BackColor = Color.SkyBlue; 
     } 
     else 
     { 
      e.RowElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local); 
      e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local); 
      e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local); 
     } 
    } 
+0

http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/selecting/row-selection/defaultcs.aspx请参阅此。 – rach

+0

我需要看什么? (我是新开发者...) – user3599192

+0

参考该链接并查看该链接页面下示例中的代码 – rach

回答

0

您拥有的代码是正确的,它应该更改带有已检查的第一个单元格的行的颜色。但是,有一点需要注意。复选框单元格的编辑器是永久性编辑器,只有在更改网格中的当前行后,它的值才会提交给单元格。如果这不起作用,可以在更改复选框状态后立即提交值。在这里,你可以找到如何做到这一点:http://www.telerik.com/help/winforms/gridview-editors-howto-checkboxeditor-submit-value-change.html

相关问题