能说清楚点吗?你的意思是在DataGrid的每行前面加个序号吗?

解决方案 »

  1.   

    用强类型的数据集方式,自己作出一个ID列,很EASY的。
      

  2.   

    webform or winform? if it is for webform, add a template column <asp:TemplateColumn HeaderText="序号">
       <ItemTemplate>
          <%# Container.ItemIndex+1%>
       </ItemTemplate>
     </asp:TemplateColumn>
      

  3.   

    在做table時做一個id列,之後用檢測當前的courent+1的方法每次提交時自動比當前最后一個行數加1就可以了,
      

  4.   

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

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