找回密码
 立即注册

QQ登录

只需一步,快速开始

ZenosZeng 讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-8-2 10:10  /   查看:7298  /  回复:2
在C1DataGrid for Silverlight中,如果包含DataGridCheckBoxColumn类型的列,你会发现该列中单元格处于非编辑状态时,CheckBox都被显示成灰色。



本文也将主要介绍如何改变CheckBox列处于非编辑状态时的显示样式,基本思路是在LoadedCellPresenter事件中将C1.Silverlight.DataGrid.ReadOnlyCheckBox替换为正常的CheckBox,代码如下:
  1.     void c1DataGrid1_LoadedCellPresenter(object sender, C1.Silverlight.DataGrid.DataGridCellEventArgs e)
  2.     {
  3.         if (e.Cell.Column.GetType() == typeof(C1.Silverlight.DataGrid.DataGridCheckBoxColumn))
  4.         {               
  5.             CheckBox newCheckBox = new CheckBox();
  6.                
  7.             System.Windows.Data.Binding bnd = new System.Windows.Data.Binding();
  8.             bnd.Source = e.Cell;
  9.             bnd.Path = new PropertyPath("Value");
  10.             bnd.Mode = System.Windows.Data.BindingMode.TwoWay;
  11.             newCheckBox.SetBinding(CheckBox.IsCheckedProperty, bnd);
  12.             e.Cell.Presenter.Content = newCheckBox;
  13.             e.Cell.Presenter.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
  14.             e.Cell.Presenter.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
  15.         }
  16.     }
复制代码


运行截图:


源码下载:VS2010 + ComponentOne Studio for Silverlight 2012V2
C#:

VB.NET:

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

2 个回复

倒序浏览
smodi
初级会员   /  发表于:2012-12-7 17:20:00
沙发
啥情况 这么多DEMO?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-12-7 18:10:00
板凳
回复 2楼smodi的帖子

C# + VB.NET
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部