Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

c# Winform DataGrid copy to end Column

$
0
0

I have a Datagrid with formulas, I want the formula to go to the end of the column. Currently it does the first cell of each column.

 private void button2_Click(object sender, EventArgs e)
        {


            //Part Gross ULD =(H2*I2)/L2

            int H = Convert.ToInt32(dataGridView1.CurrentRow.Cells[7].Value);
            var I = Convert.ToDecimal(dataGridView1.CurrentRow.Cells[8].Value);
            int L = Convert.ToInt32(dataGridView1.CurrentRow.Cells[11].Value);
            var J = H * I / L;
            dataGridView1.CurrentRow.Cells[9].Value = J;
                       
            //ULD Stack =rounddown(106/S2,0)
            int S = Convert.ToInt32(dataGridView1.CurrentRow.Cells[18].Value);
            int A = 106 ;
            int T = A / S;
            dataGridView1.CurrentRow.Cells[19].Value = T;

            //Stacks Wide =rounddown(96/R2,0) 
            int R = Convert.ToInt32(dataGridView1.CurrentRow.Cells[17].Value);
            int B = 96;
            int U = B / R;
            dataGridView1.CurrentRow.Cells[20].Value = U;

            //Stacks Day =roundup(J2/T2,0) FIX IT
            int Gross = Convert.ToInt32(dataGridView1.CurrentRow.Cells[9].Value);
            int Stack = Convert.ToInt32(dataGridView1.CurrentRow.Cells[19].Value);
            int V = Stack / Gross;
            dataGridView1.CurrentRow.Cells[21].Value = V;

            //Linear FT Stack =Q2/12
            Decimal Q = Convert.ToInt32(dataGridView1.CurrentRow.Cells[16].Value);
            var C = 12;
            Decimal W = Q / C;
            dataGridView1.CurrentRow.Cells[22].Value = W;

            //Raw Linear Ft Day =(V2*W2)/U2 FIX IT
            int V21 = Convert.ToInt32(dataGridView1.CurrentRow.Cells[21].Value);
            var W22 = Convert.ToDecimal(dataGridView1.CurrentRow.Cells[22].Value);
            int U20 = Convert.ToInt32(dataGridView1.CurrentRow.Cells[20].Value);
            var X = V21 * W22 / U20;
            dataGridView1.CurrentRow.Cells[23].Value = X;


        }
    }
}


Booney440


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>