Looping each row in datagridview

后端 未结 2 1804
温柔的废话
温柔的废话 2020-12-06 04:52

How to loop each row that readed? in my code, the row won\'t bind to next row because of the same productID, so the datagridview won\'t move to new row, it still in the same

相关标签:
2条回答
  • 2020-12-06 05:12

    You could loop through DataGridView using Rows property, like:

    foreach (DataGridViewRow row in datagridviews.Rows)
    {
       currQty += row.Cells["qty"].Value;
       //More code here
    }
    
    0 讨论(0)
  • 2020-12-06 05:25

    Best aproach for me was:

      private void grid_receptie_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            int X = 1;
            foreach(DataGridViewRow row in grid_receptie.Rows)
            {
                row.Cells["NR_CRT"].Value = X;
                X++;
            }
        }
    
    0 讨论(0)
提交回复
热议问题