devGridView第一列显示行号

//第一列增加行号
 GridViewl.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler( GridView_CustomDrawRowIndicator); 
   void GridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            //第一列增加行号
            if (e.Info 

.IsRowIndicator)
            {
                //if (this.IsGroupRow(e.RowHandle) == false)
                if (e.RowHandle >= 0)
                {
                    e.Info 

.DisplayText = Convert.ToInt32(e.RowHandle + 1).ToString();
                }
            }
        }
//设置宽度
        void GridView_RowCountChanged(object sender, EventArgs e)
        {
            //动态设置第一列的宽度
            string MeasureString = String.Format("{0}WA", rptGridControl1.GridView.RowCount);
            rptGridControl1.GridView.IndicatorWidth = this.rptGridControl1.CreateGraphics().MeasureString(MeasureString, new Font("宋体", 9)).ToSize().Width;
        }

 

posted @ 2017-11-20 16:15  LongBar  阅读(1544)  评论(0编辑  收藏  举报