在datagridview中rowpostpaint事件中如下寫法:
privatevoiddatagridviewapplydetail_rowpostpaint(objectsender,datagridviewrowpostpainteventargse)
{
rectanglerectangle=newrectangle(e.rowbounds.location.x,e.rowbounds.location.y,datagridviewapplydetail.rowheaderswidth-4,e.rowbounds.height);
textrenderer.drawtext(e.graphics,(e.rowindex+1).tostring(),datagridviewapplydetail.rowheadersdefaultcellstyle.font,rectangle,
datagridviewapplydetail.rowheadersdefaultcellstyle.forecolor,
textformatflags.verticalcenter|textformatflags.right);
}
在datagridview中rowpostpaint事件中如下寫法:
privatevoiddatagridviewapplydetail_rowpostpaint(objectsender,datagridviewrowpostpainteventargse)
{
rectanglerectangle=newrectangle(e.rowbounds.location.x,e.rowbounds.location.y,datagridviewapplydetail.rowheaderswidth-4,e.rowbounds.height);
textrenderer.drawtext(e.graphics,(e.rowindex+1).tostring(),datagridviewapplydetail.rowheadersdefaultcellstyle.font,rectangle,
datagridviewapplydetail.rowheadersdefaultcellstyle.forecolor,
textformatflags.verticalcenter|textformatflags.right);
}