如题

解决方案 »

  1.   

    private void dataGrid1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) 
     

     
         int row = TopRow(); 
     
         int yDelta = dataGrid1.GetCellBounds(row, 0).Height + 1; 
     
         int y = dataGrid1.GetCellBounds(row, 0).Top + 2; 
     
          
     
         CurrencyManager cm = (CurrencyManager) this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember]; 
     
         while(y < dataGrid1.Height - yDelta && row < cm.Count) 
     
         { 
     
              //get & draw the header text... 
     
              string text = string.Format("row{0}", row); 
     
              e.Graphics.DrawString(text, dataGrid1.Font, new SolidBrush(Color.Black), 12, y); 
     
              y += yDelta; 
     
              row++; 
     
         }