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