同样是重载onpaint 方法,但是方法应该是比较巧妙的!而且不用担心标题是不是有显示,也不用去计算坐标,很方便的说!
protected override void onpaint(painteventargs e)
{
base.onpaint(e);
if(this.datasource!=null)
{
if( this.visiblerowcount == 0 )return;
rectangle currrct;
int irowcount = this.visiblerowcount;
string stext = "";
int nowy = 0;
for( int i = 0 ; i < irowcount ; i++ )
{
currrct = (rectangle)this.getcellbounds( i, 0 );
nowy = currrct.y + 2;
stext = string.format( " {0}", i+1 );
e.graphics.drawstring( stext, this.font, new solidbrush(color.black), 10, nowy );
}
}
}
