«   2026/10   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
«   2026/10   »
일 월 화 수 목 금 토
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

DBILITY

C# 데이터그리드 ( DataGridView ) 일련번호 표시 본문

C#

C# 데이터그리드 ( DataGridView ) 일련번호 표시

DBILITY 2018. 2. 9. 22:35
반응형

RowHeader에 표시하는건 많이 있던데,

특정셀에 해보았다. CellPaint시에..

var centerFormat = new StringFormat
{
	Alignment = StringAlignment.Center,
	LineAlignment = StringAlignment.Center
};
var cellBounds = new Rectangle(e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height);
e.PaintBackground(e.ClipBounds, true);
e.Graphics.DrawString(string.Format("{0}", e.RowIndex + 1),
						e.CellStyle.Font,
						new SolidBrush(e.CellStyle.ForeColor),
						cellBounds, centerFormat);
e.Handled = true;

 

반응형
Comments