黑马程序员技术交流社区
标题:
winform中datagridView的表头要不提供排序,该如何实现?
[打印本页]
作者:
hongiqnglik
时间:
2013-8-13 23:17
标题:
winform中datagridView的表头要不提供排序,该如何实现?
winform中datagridView的表头要不提供排序,该如何实现?
作者:
咖喱猫
时间:
2013-8-13 23:23
本帖最后由 咖喱猫 于 2013-8-13 23:27 编辑
不知道是不是你想要的效果:
想要让DataGridView的左边列自动显示数字,需要在DataGridView的RowPostPant事件里面写上如图代码就会自动显示数字。
{
System.Drawing.Rectangle rectangle =
new System.Drawing.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);
}
复制代码
DataGridView左边默认第一列显示数字.png
(4.73 KB, 下载次数: 7)
下载附件
2013-8-13 23:25 上传
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2