文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 电脑基础知识 > C# 中的datagridview添加行号
侵权投诉

C# 中的datagridview添加行号

C# 中的datagridview添加行号

using System .Drawing .Printing;
using System.Drawing.Text;
using System.Drawing ;



DataGridView dgv_cght_qd = this["cght_qd"] as DataGridView;
if(dgv_cght_qd != null)
{
#region 增加EventHandler
dgv_cght_qd.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(dgv_cght_qd_CellValueChanged);
dgv_cght_qd.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(dgv_cght_qd_CellValidating);
dgv_cght_qd.RowsRemoved += new System.Windows.Forms.DataGridViewRowsRemovedEventHandler(dgv_cght_qd_RowsRemoved);
dgv_cght_qd.RowEnter += new DataGridViewCellEventHandler(dgv_cght_qd_RowEnter);
dgv_cght_qd.CellLeave += new DataGridViewCellEventHandler(dgv_cght_qd_CellLeave);
}





//2012.7.11 于传庆添加行号
dgv_sqdqd.CellPainting+=new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dgv_sqdqd_CellPainting);
private void dgv_sqdqd_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
{
//判断是不是列Header
if (e.ColumnIndex < 0 && e.RowIndex >= 0)
{
//单元格描绘
e.Paint(e.ClipBounds, DataGridViewPaintParts.All);
//决定行号码描绘的范围
//不管e.AdvancedBorderStyle和e.CellStyle.Padding
Rectangle indexRect = e.CellBounds; indexRect.Inflate(-2, -2);
//行号码描绘
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), e.CellStyle.Font, e.CellBounds, e.CellStyle.ForeColor, TextFormatFlags.Right );
//描绘完后通知
e.Handled = true;
}
}

第1页

你可能喜欢

热门文档

相关文档

  • DataGridView添加行号

    /* #region dataGridView //显示行号 private void dataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new...

  • C#中获取文件路径、DataGridView显示行号

    C#中获取文件路径、DataGridView 显示行号 中获取文件路径、 中获取文件路径我现在添加了一个 textbox 控件,在添加了一个 button,我希望完成的是当点击 Button 的...

  • 让DataGridView显示行号

    让DataGridView显示行号_IT/计算机_专业资料。c#编程让DataGridView 显示行号 DataGridView 默认的属性中,不可设置显示行号。 效果如下: 为了表示行号,我们可以在 ...

  • datagridview显示行号

    datagridview显示行号_IT/计算机_专业资料。datagridview显示行号在WinFrom 下 DataGridView 显示行号,其实是对界面上的行绘制了一个数字,感觉还 不错. private ...

  • DataGridView显示行号的二种方法

    DataGridView显示行号的二种方法_计算机软件及应用_IT/计算机_专业资料。方法一:网上最常见的做法是用 DataGridView 的 RowPostPaint 事件在 RowHeaderCell 中绘制...

  • dataGridView显示行号事件

    dataGridView显示行号事件_计算机软件及应用_IT/计算机_专业资料。dataGridView显示行号事件private void dataGridView1_RowPostPaint(object sender, DataGridViewRow...

  • 在dategridview中显示行号

    --显示 datagridview 的行号 private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { System.Drawing.Rectangle rectangle =...

  • C#中DataGridView控件使用大全

    DataGridView 控件增加新的行,该函数 返回添加新行的索引号, 即新行的行号,然后...即:DataGridView1.AutoResizeRow (0) 和 DataGridView1.AutoResizeRows() c,临时...

  • C#中向DataGridview中增添一行数据则么添加

    C#中向DataGridview中增添一行数据则么添加_计算机硬件及网络_IT/计算机_专业资料。今日推荐 180份文档 2014证券从业资格考试 2014证券资格证券交易高分突破试卷及...

  • C# DataGridView添加右键菜单等技巧

    给 dataGridView1 的 CellMouseDown 事件添加处理程序: 复制内容到剪贴板 e) { if (e.Button == MouseButtons.Right) { if (e.RowIndex >= 0) { //若行...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email