• 在列表中添加序号列


    在列表中添加序号,序号随着列的增加而增加,同时又不会影响到ItemSource的赋值,即不需在列表绑定的类中添加一个绑定序号的字段。


    定义类:

     1  public class NumColumn : Telerik.Windows.Controls.GridViewColumn
     2     {
     3         public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
     4         {
     5             TextBlock textBlock = cell.Content as TextBlock;
     6 
     7             if (textBlock == null)
     8             {
     9                 textBlock = new TextBlock();
    10             }
    11 
    12             textBlock.Text = (this.DataControl.Items.IndexOf(dataItem) + 1).ToString();
    13 
    14             return textBlock;
    15         }
    16 
    17     }

    然后在xaml中引用这个类:

    xmlns:local="clr-namespace:CSNMSSL.csnms.controls(命名空间)"

     <telerik:RadGridView ShowGroupPanel="False" AutoGenerateColumns="False"
                             IsReadOnly="True" IsFilteringAllowed="False" 
                             RowIndicatorVisibility="Collapsed" CanUserFreezeColumns="False" CanUserSelect="True"
                             RowStyle="{StaticResource TssGridViewRowStyle}" x:Name="cutList" Grid.Row="0" FontFamily="Arial"  FontSize="12" >
                            <telerik:RadGridView.Columns>
                                <local:NumColumn Header="序号" Width="40"/>
  • 相关阅读:
    Spring Cloud
    Hibernate 缓存
    Spring 快速入门
    Junit 单元测试
    Spring Cloud 笔记
    Swagger SpringBoot 集成
    Apache Shiro 权限框架
    Spring Boot
    跨域问题
    BeX5 常见问题解决办法
  • 原文地址:https://www.cnblogs.com/lh-V/p/3422749.html
Copyright © 2020-2023  润新知