2013-03-06 72 views
0

我想知道如何根據行過濾器找到列的平均值?如何計算濾波後最後一行中radgridview中每列的平均值?

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; 


    } 
} 

此代碼只給我平均沒有基於過濾的平均值?

回答

0

您可以在彙總行中使用此功能。更多的信息可以獲得here