gridView显示行号

Posted on 2010-07-13 16:20  言士心  阅读(1332)  评论(0编辑  收藏  举报

1、设置显示编号的宽度

   IndicatorWidth设置成所适合大小

2、在CustomDrawRowIndicator事件中编写如下代码

  #region 设置行号

        private void gvUser_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            int rowIndex = e.RowHandle;
            if(rowIndex>=0)
            {
                 rowIndex++;
                e.Info.DisplayText = rowIndex.ToString();
            }
            e.Info.ImageIndex = -1;
        }

 #endregion

Copyright © 2024 言士心
Powered by .NET 9.0 on Kubernetes