private void GridViewClickHandler(object sender, DataGridViewCellEventArgs e) { JcwDataGridView gridView = sender as JcwDataGridView; if (gridView != null && gridView.CurrentRow != null) { // Validate that the row being edited in fact can be edited by checking the CanIncludeInAggregate property on the data bound object. ChartStatistic statistic = gridView.CurrentRow.DataBoundItem as ChartStatistic; if (statistic != null) { if (statistic.CanIncludeInAggregate) { // If the current cell is the include column cell, raise the recalculate aggregate event. if (gridView.CurrentCell.ColumnIndex.Equals(IncludeColumn.Index)) { if (OnRecalculateAggregate != null) { OnRecalculateAggregate(this, EventArgs.Empty); } } } else { gridView.CancelEdit(); } } } }
private void GridView_CurrentCellDirtyStateChanged(object sender, EventArgs e) { JcwDataGridView gridView = sender as JcwDataGridView; if (gridView != null) { // Validate that the row being edited in fact can be edited by checking the CanIncludeInAggregate property on the data bound object. ChartStatistic statistic = gridView.CurrentRow.DataBoundItem as ChartStatistic; if (statistic != null) { if (statistic.CanIncludeInAggregate) { // Commit the change when a checkbox cell is clicked so that by the time we get into the CellContentClick // handler the cells value has already been updated. if (gridView.CurrentCell is DataGridViewCheckBoxCell) { gridView.CommitEdit(DataGridViewDataErrorContexts.Commit); } } } } }
public void EndLoadData() { // Populate min/max/ave lists that grid view will use as datasources. The data will come from the series collection // and will include calculated aggregates of the series information as well. if (Series.Count > 0) { if (Series.ContainsKey(StatisticTypes.Minimum)) { List <double> vector = new List <double> (); foreach (IJcwChartStatistic statistic in Series[StatisticTypes.Minimum]) { m_minValues.Add(statistic); if (statistic.IncludeInAggregate) { vector.Add(statistic.Value); } } double average = Utilities.GetAverage(vector); IJcwChartStatistic averageStatistic = new ChartStatistic() { Name = "Average", Value = average, IncludeInAggregate = false, CanIncludeInAggregate = false }; m_minValues.Add(averageStatistic); double stdDev = Utilities.GetStandardDeviation(vector); IJcwChartStatistic stdDevStatistic = new ChartStatistic() { Name = "Standard Deviation", Value = stdDev, IncludeInAggregate = false, CanIncludeInAggregate = false }; m_minValues.Add(stdDevStatistic); } if (Series.ContainsKey(StatisticTypes.Maximum)) { List <double> vector = new List <double> (); foreach (IJcwChartStatistic statistic in Series[StatisticTypes.Maximum]) { m_maxValues.Add(statistic); if (statistic.IncludeInAggregate) { vector.Add(statistic.Value); } } double average = Utilities.GetAverage(vector); IJcwChartStatistic averageStatistic = new ChartStatistic() { Name = "Average", Value = average, IncludeInAggregate = false, CanIncludeInAggregate = false }; m_maxValues.Add(averageStatistic); double stdDev = Utilities.GetStandardDeviation(vector); IJcwChartStatistic stdDevStatistic = new ChartStatistic() { Name = "Standard Deviation", Value = stdDev, IncludeInAggregate = false, CanIncludeInAggregate = false }; m_maxValues.Add(stdDevStatistic); } if (Series.ContainsKey(StatisticTypes.Average)) { List <double> vector = new List <double> (); foreach (IJcwChartStatistic statistic in Series[StatisticTypes.Average]) { m_aveValues.Add(statistic); if (statistic.IncludeInAggregate) { vector.Add(statistic.Value); } } double average = Utilities.GetAverage(vector); IJcwChartStatistic averageStatistic = new ChartStatistic() { Name = "Average", Value = average, IncludeInAggregate = false, CanIncludeInAggregate = false }; m_aveValues.Add(averageStatistic); double stdDev = Utilities.GetStandardDeviation(vector); IJcwChartStatistic stdDevStatistic = new ChartStatistic() { Name = "Standard Deviation", Value = stdDev, IncludeInAggregate = false, CanIncludeInAggregate = false }; m_aveValues.Add(stdDevStatistic); } } MinDataGridView.Refresh(); MaxDataGridView.Refresh(); AveDataGridView.Refresh(); }