110,533
社区成员
发帖
与我相关
我的任务
分享
int irowcount = this.dgView.DisplayedRowCount(true);
if (irowcount == 0) return;
Rectangle currrct;
int startNo = this.dgView.FirstDisplayedCell.RowIndex;
string stext = "";
int nowy = 0;
int hDelta = 0;
for (int i = startNo; i < startNo + irowcount; i++)
{
currrct = (Rectangle)this.dgView.GetCellDisplayRectangle(1, i, true);
nowy = currrct.Y + 2;
stext = string.Format("{0, 3}", i + 1);
if (hDelta == 0)
hDelta = (currrct.Height - this.Font.Height) / 2;
if (this.dgView.Rows[i].Selected == true)
e.Graphics.DrawString(stext, this.Font, new SolidBrush(Color.White), 10, nowy + hDelta);
else
e.Graphics.DrawString(stext, this.Font, new SolidBrush(Color.Black), 10, nowy + hDelta);
}