bod.docx - private void button1_Click(object sender EventArgs e cfw dataGridView1.ColumnCount = 4 dataGridView1.Columns[0.HeaderText =\"Year

bod.docx - private void button1_Click(object sender...

This preview shows page 1 - 3 out of 4 pages.

private void button1_Click( object sender, EventArgs e) { dataGridView1.ColumnCount = 4; dataGridView1.Columns[0].HeaderText = "Year" ; dataGridView1.Columns[0].Width = 50; dataGridView1.Columns[1].HeaderText = "Value at Begining of Year" ; dataGridView1.Columns[2].HeaderText = "Depreciation During Year" ; dataGridView1.Columns[3].HeaderText = "Total depreciation to End of Year" ; double value, life, amountleft, depreciation, orgval, totalDepreciation = 0; orgval = double .Parse(textBox1.Text); value = double .Parse(textBox1.Text); life = double .Parse(textBox2.Text); depreciation = value * 2 / life; amountleft = value; dataGridView1.Rows.Clear(); for ( int year = 1; year <= life; year++) { if (year < life) { depreciation = amountleft * 2 / life; amountleft -= depreciation; } else { depreciation = orgval - totalDepreciation; amountleft -= depreciation; } dataGridView1.Rows.Add(); if (year % 2 == 0) dataGridView1.Rows[year - 1].DefaultCellStyle.BackColor = Color .White; else dataGridView1.Rows[year - 1].DefaultCellStyle.BackColor = Color .FloralWhite; dataGridView1.Rows[year - 1].Cells[0].Value = year; dataGridView1.Rows[year - 1].Cells[1].Value = value.ToString( "c" );
Image of page 1
dataGridView1.Rows[year - 1].Cells[2].Value = depreciation.ToString(
Image of page 2
Image of page 3

You've reached the end of your free preview.

Want to read all 4 pages?

  • Fall '10
  • LI

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture