码迷,mamicode.com
首页 > 其他好文 > 详细

RadGridView添加序号列

时间:2016-09-28 15:27:48      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

    public class RowNumberColumn : GridViewDataColumn
    {
        public override System.Windows.FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
        {
            TextBlock textBlock = cell.Content as TextBlock;

            if (textBlock == null)
            {
                textBlock = new TextBlock();
            }

            //textBlock.Text = (this.DataControl.Items.IndexOf(dataItem) + 1).ToString(); 
            textBlock.Text = ((this.DataControl.ItemsSource as IList).IndexOf(dataItem) + 1).ToString();

            return textBlock;
        }
    }
<telerik:RadGridView>
    <telerik:RadGridView.Columns>
        <local:RowNumberColumn Width="32" Header="序号"/>
     </telerik:RadGridView.Columns>
</telerik:RadGridView>

 

RadGridView添加序号列

标签:

原文地址:http://www.cnblogs.com/XzcBlog/p/5916235.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!