zoukankan      html  css  js  c++  java
  • 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);
            }

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

  • 相关阅读:
    C 语言定义
    一次系统磁盘异常使用100%的处理
    supervisord 安装、配置体验
    uva 211(dfs)
    poj1651
    有一种感动叫ACM(记WJMZBMR在成都赛区开幕式上的讲话)
    nyoj-746
    Codeforces Round #308 (Div. 2)----C. Vanya and Scales
    long long 与 _int64
    石子归并问题(nyoj737)
  • 原文地址:https://www.cnblogs.com/NetPig/p/3968345.html
Copyright © 2011-2022 走看看