private void dataGridOrder_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
int row =1;
int y = 0;
//dS_GoodsOrder是dataSet
int count =this.dS_GoodsOrder.Tables[0].Rows.Count;
while( row <= count)
{
//get & draw the header text...
string text = string.Format(" {0}", row);
//dataGridOrder是dataGrid
y = this.dataGridOrder.GetCellBounds(row - 1, 0).Y + 2;
e.Graphics.DrawString(text,this.dataGridOrder.Font, new SolidBrush(Color.Black), 4, y);
row ++;
} }
{
int row =1;
int y = 0;
//dS_GoodsOrder是dataSet
int count =this.dS_GoodsOrder.Tables[0].Rows.Count;
while( row <= count)
{
//get & draw the header text...
string text = string.Format(" {0}", row);
//dataGridOrder是dataGrid
y = this.dataGridOrder.GetCellBounds(row - 1, 0).Y + 2;
e.Graphics.DrawString(text,this.dataGridOrder.Font, new SolidBrush(Color.Black), 4, y);
row ++;
} }
{
DataTable dt = (DataTable)dataGrid1.DataSource;
if(dt==null || dt.Rows.Count <=0 ) return;
int row=0;
int y=0;
int i=dt.Rows.Count;
while(row<i)
{
string text=string.Format(" {0}",row+1);
y=this.dataGrid1.GetCellBounds(row,0).Y+2;
e.Graphics.DrawString(text,this.dataGrid1.Font ,new SolidBrush(Color.Black), 4, y);
row++;
}
}