/// <summary> /// </summary> /// <param name="ss">The SpreadsheetPanel in the current Form1</param> private void DisplaySelection(SpreadsheetPanel ss) { if (_spreadsheet == null) { return; } int col, row; ss.GetSelection(out col, out row); // Convert col, row index to spreadsheet cell names. var cellName = ((char)(col + 65)) + (row + 1).ToString(CultureInfo.InvariantCulture); // Displays selected cell's name CellNameBox.Invoke(new Action(() => { CellNameBox.Text = cellName; })); var content = _spreadsheet.GetCellContents(cellName); // If content is a formula, prepend "=" before displaying var f = content as Formula; if (f != null) { ContentBox.Invoke(new Action(() => { ContentBox.Text = "=" + f; })); } // Otherwise just display the content. else { ContentBox.Invoke(new Action(() => { ContentBox.Text = content.ToString(); })); } // No need to fetch the value from the spreadsheet again, just copy it from // the spreadsheetpanel. This avoids reworking the FormulaError message. string value; ss.GetValue(col, row, out value); ValueBox.Invoke(new Action(() => { ValueBox.Text = value; })); }
private void CleanSpreadsheet() { DeregisterHandlers(); _spreadsheet = null; spreadsheetPanel1.Invoke(new Action(() => { spreadsheetPanel1.Clear(); })); CellNameBox.Invoke(new Action(() => { CellNameBox.Text = string.Empty; })); ValueBox.Invoke(new Action(() => { ValueBox.Text = string.Empty; })); ContentBox.Invoke(new Action(() => { ContentBox.Text = string.Empty; })); this.Invoke(new Action(() => { this.Text = "Spreadsheet Program - Not Connected"; })); }
private void DisplayUpdate(SpreadsheetPanel ss) { if (_spreadsheet == null) { return; } int col, row; ss.GetSelection(out col, out row); // Convert col, row index to spreadsheet cell names. var cellName = ((char)(col + 65)) + (row + 1).ToString(CultureInfo.InvariantCulture); // Displays selected cell's name CellNameBox.Invoke(new Action(() => { CellNameBox.Text = cellName; })); // No need to fetch the value from the spreadsheet again, just copy it from // the spreadsheetpanel. This avoids reworking the FormulaError message. string value; ss.GetValue(col, row, out value); ValueBox.Invoke(new Action(() => { ValueBox.Text = value; })); }