DevExpress Gridcontrol 自动显示序号列(转)

DevExpress Gridcontrol显示序号列,用 gridView1_CustomDrawRowIndicator 的事件来实现。具体代码如下:

#region gridView1_CustomDrawRowIndicator
        /// <summary>
        /// 显示序号。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator && e.RowHandle >= 0)
            {
                e.Info.DisplayText = (e.RowHandle + 1).ToString();
            }
        }
        #endregion

 

序号列的宽度设置gridView 的IndicatorWidth属性即可。

posted @ 2016-05-24 09:05  武道巅峰  阅读(3581)  评论(0编辑  收藏  举报