dataGridView序号问题。

kxxl 2006-08-13 10:41:36
dataGridView如何才能让每行前边加上系统给的序号呢?

我说的不是数据库中的自动编号,是每行前边的序号123456789
...全文
434 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengyunhongri 2006-08-21
  • 打赏
  • 举报
回复
另外加一列序号列,在绑定事件中根据行索引和页码写入自动编号。
joeweng 2006-08-21
  • 打赏
  • 举报
回复
DATAGRIDVIEW 增加一个RowPostPaint 事件


private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor))
{
e.Graphics.DrawString(e.RowIndex.ToString(System.Globalization.CultureInfo.CurrentUICulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
}
woaichenyu 2006-08-15
  • 打赏
  • 举报
回复
Knight94 2006-08-14
  • 打赏
  • 举报
回复
参看
http://www.codeproject.com/books/PresentDataDataGridView.asp

中的“Utilizing Cell-Oriented Grid Features”这部分。

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧