zoukankan      html  css  js  c++  java
  • C1DataGrid for Silverlight 修改 CheckBox 列外观

    在C1DataGrid for Silverlight中,如果包含DataGridCheckBoxColumn类型的列,你会发现该列中单元格处于非编辑状态时,CheckBox都被显示成灰色。
    C1DataGrid

    本文也将主要介绍如何改变CheckBox列处于非编辑状态时的显示样式,基本思路是在LoadedCellPresenter事件中将C1.Silverlight.DataGrid.ReadOnlyCheckBox替换为正常的CheckBox,代码如下:

        void c1DataGrid1_LoadedCellPresenter(object sender, C1.Silverlight.DataGrid.DataGridCellEventArgs e)
        {
            if (e.Cell.Column.GetType() == typeof(C1.Silverlight.DataGrid.DataGridCheckBoxColumn))
            {                
                CheckBox newCheckBox = new CheckBox();
                    
                System.Windows.Data.Binding bnd = new System.Windows.Data.Binding();
                bnd.Source = e.Cell;
                bnd.Path = new PropertyPath("Value");
                bnd.Mode = System.Windows.Data.BindingMode.TwoWay;
                newCheckBox.SetBinding(CheckBox.IsCheckedProperty, bnd);
                e.Cell.Presenter.Content = newCheckBox;
                e.Cell.Presenter.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                e.Cell.Presenter.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            }
        }
    

    运行截图:

    源码下载:VS2010 + ComponentOne Studio for Silverlight 2012V2
    1.C#                    2.VB.NET

  • 相关阅读:
    vue官方实例-组件
    数据处理-js
    图片大于div时的居中显示
    angularjs select通过动态加载option有空白项的处理方法-
    背景图片自适应div
    input-text
    input-number-required
    input-number-not-required
    null与undefined的区别?
    是true还是false呢?
  • 原文地址:https://www.cnblogs.com/C1SupportTeam/p/2621839.html
Copyright © 2011-2022 走看看