protected void PaintMe(object sender, PaintEventArgs e)
{
try{
if(needBorder){
this.BorderStyle = BorderStyle.None;
Pen pen = new Pen(Color.FromArgb(0,0,102),1);
e.Graphics.DrawRectangle(pen,0,0,this.Width-1,this.Height-1);
}

if(false==showRowSequenceNumber)return;
if(false==this.TableStyles[0].RowHeadersVisible)return; int row = TopRow();
if(row<0)return; int yDelta = this.GetCellBounds(row, 0).Height + 1;
int y = this.GetCellBounds(row, 0).Top + 2;

int from = this.FirstVisibleColumn;
int to = from + this.VisibleColumnCount;
int x;
string str=""; CurrencyManager cm = (CurrencyManager) this.BindingContext[this.DataSource, this.DataMember]; while(y < this.Height - yDelta && row < cm.Count){
FontColorEventArgs ea = new FontColorEventArgs(row);
OnSetFontColor(ea);
if(ea.UseCustom){
for(int i=from+1;i<to;i++){
str = Convert.ToString(this[row,i]);
x = this.GetCellBounds(row,i).Left;
e.Graphics.DrawString(str, this.Font, new SolidBrush(ea.FontColor),x,y);
}
} //get & draw the header text...
string text = string.Format("{0}", row+1);
e.Graphics.DrawString(text, this.Font, new SolidBrush(Color.Black), 4, y);
yDelta = this.GetCellBounds(row, 0).Height + 1;//防止拖动每行的时候,字体位置写错了。
y += yDelta;
row++;
}
}
catch{}
}我们的部分代码,参考了synfusion的很多内容。