Devexpress的GridControl如何加入行号显示

来源:互联网 发布:ubuntu 安装 分区 编辑:程序博客网 时间:2024/05/17 22:13
//要设置一下.IndicatorWidth,要不然列会被遮挡,这个就是没有列头的第一列

this.gridView1.IndicatorWidth = 40; //一般够放下5位数,可自行测试

//显示行的序号

privatevoid gridView1_CustomDrawRowIndicator(object sender,RowIndicatorCustomDrawEventArgs e)

{

e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            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();
                }
            }

}

看一下效果图:




0 0
原创粉丝点击