Make the result of a subform were in the same form a

Make the result of a subform were in the same form a

I would like to make the result of a subform were in the same form as the application : Order management .

I have the following codes, and it works, but I can not transfer it to the form.

row.Total=(row.Piezas  *  row.Precio);
itemtotal=0.0;
for each Sub_Total in Articulos
{
if(Sub_Total.Total  !=  null)
{
itemtotal=(itemtotal  +  Sub_Total.Total);
}
}
Total=itemtotal;

-------------------------

for each Item in Articulos
{
    input.Precio = (input.Precio  +  row.Total);
}


Thanks!