给dataGrid1的事件Paint写方法如下:
private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
   int intRow =0; 
   int intCellHehight = dataGrid1.GetCellBounds(intRow, 0).Height + 1; 
   int intY = dataGrid1.GetCellBounds(intRow, 0).Top + 2; 

  e.Graphics.DrawString("选项", dataGrid1.Font, new SolidBrush(Color.Black), 5, intY-intCellHehight-1); 
    CurrencyManager cm = (CurrencyManager) this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember]; 
 
    while(intY < dataGrid1.Height - intCellHehight && intRow < cm.Count) 
  { 
   //get & draw the header text... 
   string text = string.Format("{0}", (intRow+65)); 
   e.Graphics.DrawString(text, dataGrid1.Font, new SolidBrush(Color.Black), 12, intY); 
   intY += intCellHehight; 
   intRow++; 
  } 

}

解决方案 »

  1.   

    上贴重写如下:
    -----------------------------------------
    给dataGrid1的事件Paint写方法如下:
    private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
       int intRow =0; 
       int intCellHehight = dataGrid1.GetCellBounds(intRow, 0).Height + 1; 
       int intY = dataGrid1.GetCellBounds(intRow, 0).Top + 2; 

      e.Graphics.DrawString("行号", dataGrid1.Font, new SolidBrush(Color.Black), 5, intY-intCellHehight-1); 
        CurrencyManager cm = (CurrencyManager) this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember]; 
     
        while(intY < dataGrid1.Height - intCellHehight && intRow < cm.Count) 
      { 
       //get & draw the header text... 
       string text = string.Format("{0}", (intRow+1)); 
       e.Graphics.DrawString(text, dataGrid1.Font, new SolidBrush(Color.Black), 12, intY); 
       intY += intCellHehight; 
       intRow++; 
      } 

    }