0

我想知道如何根据行过滤器找到列的平均值?

private void monthlyGridView_Click(object sender, EventArgs e)
{
   List<double> everyQuestion = new List<double>();

    for (int i = 5; i < monthlyGridView.Columns.Count; i++)
    {
        eachQuestion.Clear();
       for (int j = 0; j < monthlyGridView.Rows.Count - 2; j++)
       {
          //mReport is DataTable which return values
          string value = mReport.Rows[j][i].ToString();
          eachQuestion.Add(double.Parse(value));
       }
          string columnAverage = String.Format("{0:0.00}", eachQuestion.Average());
          monthlyGridView.Rows[monthlyGridView.Rows.Count - 1].Cells[i].Value = columnAverage;


    }
}

这段代码只给我平均值而不是基于过滤的平均值?

4

1 回答 1

0

您可以为此功能使用内置摘要行。更多信息可 在此处获得

于 2013-03-08T09:47:26.657 回答