网格视图单元格在小计网格视图的脚下自动添加0

时间:2013-01-23 18:15:16

标签: c# .net vb.net datagridview

为什么网格视图单元格在小计网格视图的脚下自动添加0?

        int qty = 0;
        int amount = 0;
        int rowtotal = 0;
        int subtotal = 0;
        int total = 0;

        foreach (DataGridViewRow row in itemgridview.Rows)
        {
            qty = Convert.ToInt32(row.Cells[1].Value); 
            amount = Convert.ToInt32(row.Cells[2].Value); 
            rowtotal = qty * amount;
            row.Cells[3].Value = rowtotal;
            subtotal += rowtotal;

        }

        total = subtotal;
        txtordertotal.Text = total.ToString();

1 个答案:

答案 0 :(得分:0)

制作AllowUsersToAddRow = false,然后再试一次。此属性将移除额外的行。