如何在devexpress gridcontrol上显示行号

来源:互联网 发布:如何注册淘宝小号 编辑:程序博客网 时间:2024/05/21 17:00

   private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
                e.Appearance.TextOptions.HAlignment=DevExpress.Utils.HorzAlignment.Far;
                if (e.Info.IsRowIndicator)
                {
                    if (e.RowHandle >= 0)
                    {
                        e.Info.DisplayText =  (e.RowHandle+1).ToString();
                    }
                    else if (e.RowHandle < 0 && e.RowHandle > -1000)
                    {
                        e.Info.Appearance.BackColor = System.Drawing.Color.AntiqueWhite;
                        e.Info.DisplayText = "G" + e.RowHandle.ToString();
                    }
                }
        }

 

注意:要设置好indicatorwidth为30