• DevExpress中gridView行号的显示


     

    我们在进行开发的时候,很多地方希望dataGridview或girdView显示行号,这里我来说一下两种的实现方法

    在girdView中很简单很好实现,我在这里写一下代码,具体其他功能可以看其带的DEMO,

        private void dataGridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
         {
            if (e.Info.IsRowIndicator)
            {
                e.Info.DisplayText = Convert.ToString(e.RowHandle + 1);
             }
         }

    我们再看一下vs自带的dataGridView中行号的实现方法

    private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
            {
                Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
                   e.RowBounds.Location.Y,
                   dataGridView1.RowHeadersWidth - 4,
                   e.RowBounds.Height);

                TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                    dataGridView1.RowHeadersDefaultCellStyle.Font,
                    rectangle,
                    dataGridView1.RowHeadersDefaultCellStyle.ForeColor,
                    TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
            }

    不过多解释了,如果需要拷贝即可使用,呵呵

  • 相关阅读:
    Ansible中文权威指南学习
    gitlab
    Python-Day01-task
    Python-Day01
    CentOs6.7 python2.6升级到2.7.11
    网站访问慢排查方法及解决方案
    LAMP环境下zabbix安装配置
    监控知识点概述
    Java抽象类、接口和内部类
    Java 访问控制
  • 原文地址:https://www.cnblogs.com/flyhigh1860/p/2755229.html
Copyright © 2020-2023  润新知