同样是重载OnPaint 方法,但是方法应该是比较巧妙的!而且不用担心标题是不是有显示,也不用去计算坐标,很方便的说!
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if(this.DataSource!=null)
{
if( this.VisibleRowCount == 0 )return;
Rectangle currRct;
int iRowCount = this.VisibleRowCount;
string sText = "";
int nowY = 0;
for( int i = 0 ; i < iRowCount ; i++ )
{
currRct = (Rectangle)this.GetCellBounds( i, 0 );
nowY = currRct.Y + 2;
sText = string.Format( " {0}", i+1 );
e.Graphics.DrawString( sText, this.Font, new SolidBrush(Color.Black), 10, nowY );
}
}
}
DataGrid(WinForm)显示行号最简单的方法
来源:搜站长搜集
作者:未知
时间:2005-10-23
点击:
最新评论共有 0 位网友发表了评论
查看所有评论
发表评论
- 赞助商连接
热点关注
- .NET中各种数据库连接大全
- DataGrid相关知识总结(收
- sql server 与 excel 互导
- DataGrid数据导入Excel
- DataGrid使用技巧
- ADO.NET学习笔记(三篇)
- DataGrid 动态列
- VB.NET 导出数据到EXCEL中
- 使用DataReader还是DataSe
- DataGrid(WinForm)显示行
- 在ADO.NET数据集中浏览多
- Sql与Asp.Net数据类型对应
- DataGrid中加多选按钮
- Web中DataGrid绑定数据显
- ASP.NET中数据库数据导入E
- 经常用到的交叉表问题,一
- SQL查询语句对象化的实现
- 统一身份认证子系统数据库
- ASP.NET中数据库数据导入E
- SQL server 系统储存过程