Esempio n. 1
0
        // Every time the selection changes, this method is called with the
        // Spreadsheet as its parameter.  We display the current time in the cell.

        private void displaySelection(SpreadsheetPanel ss)
        {
            int row, col;
            String value;
            ss.GetSelection(out col, out row);
            ss.GetValue(col, row, out value);
            if (value == "") 
            {
                ss.SetValue(col, row, DateTime.Now.ToLocalTime().ToString("T"));
                ss.GetValue(col, row, out value);
                MessageBox.Show("Selection: column " + col + " row " + row + " value " + value);
            }
        }
Esempio n. 2
0
        // Every time the selection changes, this method is called with the
        // Spreadsheet as its parameter.  We display the current time in the cell.

        private void displaySelection(SpreadsheetPanel ss)
        {
            int    row, col;
            String value;

            ss.GetSelection(out col, out row);
            ss.GetValue(col, row, out value);
            if (value == "")
            {
                ss.SetValue(col, row, DateTime.Now.ToLocalTime().ToString("T"));
                ss.GetValue(col, row, out value);
            }
        }
Esempio n. 3
0
        // Every time the selection changes, this method is called with the
        // Spreadsheet as its parameter.  We display the current time in the cell.

        private void displaySelection(SpreadsheetPanel ss)
        {
            int    row, col;
            String value;

            ss.GetSelection(out col, out row);
            ss.GetValue(col, row, out value);
            if (value == "")
            {
                ss.SetValue(col, row, DateTime.Now.ToLocalTime().ToString("T"));
                ss.GetValue(col, row, out value);
                MessageBox.Show("Selection: column " + col + " row " + row + " value " + value);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This will update the displayed cell name text box, cell value text box, and cell content text box.
        ///
        /// </summary>
        private void UpdateTextBoxes(SpreadsheetPanel ss)
        {
            ss.GetSelection(out int col, out int row);
            ss.GetValue(col, row, out string value);
            string cellName = ColRowToCellName(col, row);

            CellNameUneditableTextBox.Text  = cellName;                   // Sets text box that displays cell name to the selected cell name
            CellValueUneditableTextBox.Text = value;                      // Sets text box that displays cell value to cell value of the selected cell
            CellContentTextBox.Text         = ContentToDisplay(cellName); // Sets text box that displays cell content to cell content string representatin of the selected cell
        }
        /// <summary>
        /// Helper method for updating the cell's value boxes when the selection changes
        /// This method correctly sets the value textboxes: cellNameValue, columnValue, rowValue, cellContentsValue, and the cellValueBox textboxes
        /// </summary>
        /// <param name="sheet"></param>
        private void displaySelection(SpreadsheetPanel sheet)
        {
            // Create variables for holding the row, column, and cell values
            int    row;
            int    col;
            String value;

            // Get the current selection
            sheet.GetSelection(out col, out row);
            // Get the cell's value once the selection is obtained
            sheet.GetValue(col, row, out value);

            // Add ascii offset to the column number
            int asciiCol = col + 65;

            // Convert the ascii value into a char and set it as the columnValue text box
            columnValue.Text = Char.ConvertFromUtf32(asciiCol);

            // Add 1 to the row number since rows and columns starting index is 0
            int actualRow = row + 1;

            // Convert row number to a string and store it in the rowValue text box
            rowValue.Text = actualRow.ToString();

            // Combine the column and row values as a string and set them as the cellNameValue text box
            cellNameValue.Text = Char.ConvertFromUtf32(asciiCol) + actualRow.ToString();

            // Get the contents of the cell and convert it to a string
            String cellContents = spreadSheet.GetCellContents(cellNameValue.Text).ToString();

            // Set the cell's contents in the cellContentsValue text box
            cellContentsValue.Text = cellContents;

            // Get the vlaue of the cell and convert it to a string
            String cellValue = spreadSheet.GetCellValue(cellNameValue.Text).ToString();

            // Set the clel's value in the cellValueBox textbox
            cellValueBox.Text = cellValue;
        }
        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; }));
        }
        /// <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; }));
        }