protected TableDataRow GetEntireRow(int rowIndex, bool skipFirstColumn = false) { /* Return a row data, with each column being an element in the returned array. Return null, * if there is a problem with what is being parsed. The list of problems that can arise are: * - no data found in a cell. */ if (!ValidateRow(rowIndex, skipFirstColumn)) { return(null); } TableDataRow dr = new TableDataRow(); for (int i = (skipFirstColumn) ? 1 : 0; i < m_tableView.Rows[rowIndex].Cells.Count; i++) { // start at 1 to skip the first column as it is the label column, so any data is not relevant if (CanParseToInt(m_tableView.Rows[rowIndex].Cells[i].Value.ToString())) { // add as int if it can dr.Add(DataItem.Parse(Int32.Parse(m_tableView.Rows[rowIndex].Cells[i].Value.ToString()))); } else { // if all other data types fail, add as string dr.Add(DataItem.Parse(m_tableView.Rows[rowIndex].Cells[i].Value.ToString())); } } return(dr); }
public override TableDataRow[] GetData() { /* Return an array of DataRows from the discrete table. If there is an error when getting the data from a row, * the user is asked whether they want to continue without that row in the data. */ List <TableDataRow> drlist = new List <TableDataRow>(); TableDataRow tempdr = new TableDataRow(); for (int i = 0; i < base.RowCount; i++) { tempdr = base.GetEntireRow(i, true); if (tempdr == null) { DialogResult result = MessageBox.Show("There is an error in the data of row " + (i + 1) + ". Would you like to continue?", "Invalid Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.No) { // user does not want to continue return(null); } if (result == DialogResult.Yes) { // user does want to continue so add an empty data row drlist.Add(new TableDataRow()); continue; } } drlist.Add(tempdr); } return(drlist.ToArray()); }
protected TableDataRow GetEntireColumn(int colIndex) { /* Return the data of from an entire column. Return null if there is a problem with what is being parsed. * The lsit of problems that can arise are: * - no data found in a cell. */ if (!ValidateColumn(colIndex)) { return(null); } TableDataRow data = new TableDataRow(); for (int i = 0; i < this.RowCount; i++) { data.Add(DataItem.Parse(m_tableView.Rows[i].Cells[colIndex])); } return(data); }