/// <summary> /// Set the function in the totals row. Be sure to set <see cref="HasTotalRow"/> true first. /// </summary> /// <param name="TableColumnIndex">The table column index. For example, 1 for the 1st table column, 2 for the 2nd table column and so on.</param> /// <param name="TotalsRowFunction">The function type.</param> /// <returns>True if successful. False otherwise.</returns> public bool SetTotalRowFunction(int TableColumnIndex, SLTotalsRowFunctionValues TotalsRowFunction) { if (this.TotalsRowCount > 0) { --TableColumnIndex; if (TableColumnIndex < 0 || TableColumnIndex >= this.TableColumns.Count) { return(false); } this.TableColumns[TableColumnIndex].TotalsRowLabel = null; int iStartRowIndex = -1; int iEndRowIndex = -1; if (this.HeaderRowCount > 0) { iStartRowIndex = this.StartRowIndex + 1; } else { iStartRowIndex = this.StartRowIndex; } // not inclusive of the last totals row iEndRowIndex = this.EndRowIndex - 1; int iColumnIndex = this.StartColumnIndex + TableColumnIndex; switch (TotalsRowFunction) { case SLTotalsRowFunctionValues.Average: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Average; break; case SLTotalsRowFunctionValues.Count: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Count; break; case SLTotalsRowFunctionValues.CountNumbers: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.CountNumbers; break; case SLTotalsRowFunctionValues.Maximum: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Maximum; break; case SLTotalsRowFunctionValues.Minimum: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Minimum; break; case SLTotalsRowFunctionValues.StandardDeviation: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.StandardDeviation; break; case SLTotalsRowFunctionValues.Sum: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Sum; break; case SLTotalsRowFunctionValues.Variance: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Variance; break; } this.TableColumns[TableColumnIndex].HasTotalsRowFunction = true; return(true); } else { return(false); } }
/// <summary> /// Set the function in the totals row. Be sure to set <see cref="HasTotalRow"/> true first. /// </summary> /// <param name="TableColumnIndex">The table column index. For example, 1 for the 1st table column, 2 for the 2nd table column and so on.</param> /// <param name="TotalsRowFunction">The function type.</param> /// <returns>True if successful. False otherwise.</returns> public bool SetTotalRowFunction(int TableColumnIndex, SLTotalsRowFunctionValues TotalsRowFunction) { if (this.TotalsRowCount > 0) { --TableColumnIndex; if (TableColumnIndex < 0 || TableColumnIndex >= this.TableColumns.Count) return false; this.TableColumns[TableColumnIndex].TotalsRowLabel = null; int iStartRowIndex = -1; int iEndRowIndex = -1; if (this.HeaderRowCount > 0) iStartRowIndex = this.StartRowIndex + 1; else iStartRowIndex = this.StartRowIndex; // not inclusive of the last totals row iEndRowIndex = this.EndRowIndex - 1; int iColumnIndex = this.StartColumnIndex + TableColumnIndex; switch (TotalsRowFunction) { case SLTotalsRowFunctionValues.Average: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Average; break; case SLTotalsRowFunctionValues.Count: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Count; break; case SLTotalsRowFunctionValues.CountNumbers: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.CountNumbers; break; case SLTotalsRowFunctionValues.Maximum: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Maximum; break; case SLTotalsRowFunctionValues.Minimum: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Minimum; break; case SLTotalsRowFunctionValues.StandardDeviation: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.StandardDeviation; break; case SLTotalsRowFunctionValues.Sum: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Sum; break; case SLTotalsRowFunctionValues.Variance: this.TableColumns[TableColumnIndex].TotalsRowFunction = TotalsRowFunctionValues.Variance; break; } this.TableColumns[TableColumnIndex].HasTotalsRowFunction = true; return true; } else { return false; } }