/// <summary> /// 单元格的值变更事件 /// </summary> public void GridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { MedGridView grid = (MedGridView)sender; if (MedGridViewScore != null && (MedGridViewScore.Columns[e.ColumnIndex].HeaderText == "评分")) { decimal valueTatol = 0; for (int i = 0; i < MedGridViewScore.RowCount; i++) { if (MedGridViewScore.Rows[i].Cells[e.ColumnIndex].Value != null) { decimal temp = 0; decimal.TryParse(MedGridViewScore.Rows[i].Cells[e.ColumnIndex].Value.ToString(), out temp); valueTatol += temp; } } // 计算值后生成事件参数 SYRMGridViewCellValueChangeEventArgs EventArgs = new SYRMGridViewCellValueChangeEventArgs((int)Math.Round(valueTatol)); // 异步调用值变化的事件 if (OnRefreshTotalScore != null) { OnRefreshTotalScore(sender, EventArgs); } } }
/// <summary> /// 刷新总分 /// </summary> public void RefreshScore() { int ColumnIndex = -1; for (int i = 0; i < MedGridViewScore.Columns.Count; i++) { if (MedGridViewScore != null && (MedGridViewScore.Columns[i].HeaderText == "评分")) { ColumnIndex = i; break; } } //如果没有找到 if (ColumnIndex == -1) { return; } if (MedGridViewScore != null && (MedGridViewScore.Columns[ColumnIndex].HeaderText == "评分")) { decimal valueTatol = 0; for (int i = 0; i < MedGridViewScore.RowCount; i++) { if (MedGridViewScore.Rows[i].Cells[ColumnIndex].Value != null) { decimal temp = 0; decimal.TryParse(MedGridViewScore.Rows[i].Cells[ColumnIndex].Value.ToString(), out temp); valueTatol += temp; } } // 计算值后生成事件参数 SYRMGridViewCellValueChangeEventArgs EventArgs = new SYRMGridViewCellValueChangeEventArgs((int)Math.Round(valueTatol)); // 调用值变化的事件 if (OnRefreshTotalScore != null) { OnRefreshTotalScore(MedGridViewScore, EventArgs); } } }