Пример #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int SumRows = 0;

            for (int i = 0; i < cMain.DataShow; i++)
            {
                MaxValue[i] = -65535;//初始化一个默认值
                MinValue[i] = 65535;
                SumValue[i] = 0;
            }
            for (int i = 2; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1.Rows[i].Cells[0].Value != null && Num.BoolParse(dataGridView1.Rows[i].Cells[0].Value))
                {
                    for (int j = 0; j < cMain.DataShow; j++)
                    {
                        double tmpValue = Num.DoubleParse(dataGridView1.Rows[i].Cells[1 + j].Value);
                        SumValue[j] = SumValue[j] + tmpValue;
                        MaxValue[j] = Num.DoubleMax(MaxValue[j], tmpValue);
                        MinValue[j] = Num.DoubleMin(MinValue[j], tmpValue);
                    }
                    SumRows++;
                }
            }
            if (SumRows >= 3)//最少要3行,(最高值,最低值,中间值)最少3行
            {
                for (int i = 0; i < cMain.DataShow; i++)
                {
                    double tmpValue = Num.DoubleParse(txtData.Text);
                    SumValue[i] = SumValue[i] - MaxValue[i] - MinValue[i];
                    if (chkData[i].Checked)
                    {
                        dataGridView1.Rows[0].Cells[i + 1].Value = (1 - tmpValue * 0.010) * SumValue[i] / (SumRows - 2.000);
                        dataGridView1.Rows[1].Cells[i + 1].Value = (1 + tmpValue * 0.010) * SumValue[i] / (SumRows - 2.000);
                    }
                    else
                    {
                        dataGridView1.Rows[0].Cells[i + 1].Value = 0;
                        dataGridView1.Rows[1].Cells[i + 1].Value = 0;
                    }
                }
            }
            else
            {
                if (dataGridView1.Rows.Count >= 2)
                {
                    for (int i = 0; i < cMain.DataShow; i++)
                    {
                        dataGridView1.Rows[0].Cells[i + 1].Value = 0;
                        dataGridView1.Rows[1].Cells[i + 1].Value = 0;
                    }
                }
            }
        }