Ejemplo n.º 1
0
        /// <summary>
        /// Event when the paste option is clicked on the right-click menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // If nothing has been copied, do nothing.
            if (CopyContents.ToString() == "")
            {
                return;
            }
            // Otherwise, get coordinates and name of selected cell.
            SpreadSheetPanel.GetSelection(out CurrentColumn, out CurrentRow);
            CurrentCellName = GetCellName(CurrentColumn, CurrentRow);

            // If copied cell was a formula, append an = to the beginning of the content string.
            if (CopyContents is Formula)
            {
                Spreadsheet.SetContentsOfCell(CurrentCellName, "=" + CopyContents.ToString());
            }
            // Otherwise simply add the copied contents to the cell.
            else
            {
                Spreadsheet.SetContentsOfCell(CurrentCellName, CopyContents.ToString());
            }
            // Update cells and selection values.
            Update();
            GetSelectionValues(SpreadSheetPanel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Event when delete option is clicked on the right-clikc menu.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Get selected cell's coordinates and name.
            SpreadSheetPanel.GetSelection(out CurrentColumn, out CurrentRow);



            Spreadsheet.SetContentsOfCell(CurrentCellName, "");
            // Set the displayed value and contents to ""
            SpreadSheetPanel.SetValue(CurrentColumn, CurrentRow, "");
            CellContentsField.Text = "";
            // Update cells and selection values.
            Update();
            GetSelectionValues(SpreadSheetPanel);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Event when the copy option is clicked on the right-click menu.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void copyToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // Get current selection's coordinates and name.
     SpreadSheetPanel.GetSelection(out CurrentColumn, out CurrentRow);
     CurrentCellName = GetCellName(CurrentColumn, CurrentRow);
     // Get contents of cell and store them.
     CopyContents = Spreadsheet.GetCellContents(CurrentCellName);
     // If cell is empty, the copy operation cannot be performed. Display error messgae.
     if (CopyContents.ToString() == "")
     {
         MessageBox.Show(null, "Error: Cannot copy empty cell.", "Error");
     }
     // Store the cell's value as well.
     CopyValue = Spreadsheet.GetCellValue(CurrentCellName);
 }