SpreadsheetGear 2010
CellEndEdit Event
See Also  Example Send Feedback
SpreadsheetGear.Windows.Forms Namespace > WorkbookView Class : CellEndEdit Event

Occurs when edit mode is ending and provides the ability to force edit mode to continue by cancelling the event.

Syntax

Visual Basic (Declaration) 
<CategoryAttribute("Data")>
<DescriptionAttribute("Occurs when edit mode ends.")>
Public Event CellEndEdit As CellEndEditEventHandler
C# 
[CategoryAttribute("Data")]
[DescriptionAttribute("Occurs when edit mode ends.")]
public event CellEndEditEventHandler CellEndEdit

Event Data

The event handler receives an argument of type CellEndEditEventArgs containing data related to this event. The following CellEndEditEventArgs properties provide information specific to this event.

PropertyDescription
ActiveCell Returns the active cell from the time edit mode was started.
Cancel Gets or sets the value which specifies whether the event should be canceled.
Entry Gets or sets the edit entry text.
RangeSelection Returns the range selection from the time edit mode was started.

Example

C#Copy Code
/*
         * Demonstrate the CellEndEdit event by validating that the 
         * user entered a valid integer > 0.
         */
        private void workbookView_CellEndEdit(object sender, 
            SpreadsheetGear.Windows.Forms.CellEndEditEventArgs e)
        {
            // Acquire a lock on the workbook set.
            workbookView.GetLock();
            try
            {
                // Get a reference to the active worksheet's cells.
                SpreadsheetGear.IRange cells = workbookView.ActiveWorksheet.Cells;
 
                // Check if the correct cell is selected.
                if (workbookView.RangeSelection.Equals(cells["B1"]))
                {
                    // Try to convert the entry to an integer.
                    int result;
                    bool validInt = Int32.TryParse(e.Entry, out result);
 
                    // Check if the entry is valid.
                    if (!validInt || result <= 0)
                    {
                        // Show a message and cancel CellEndEdit.
                        MessageBox.Show("The entry must be an integer greater than 0.", 
                            "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        e.Cancel = true;
                    }
                }
            }
            finally
            {
                // Release the lock on the workbook set.
                workbookView.ReleaseLock();
            }
        }

Remarks

The CellEndEdit event occurs when edit mode is being ended, and provides the event handler with the ability to modify the text to be placed into the ActiveCell, or force edit mode to continue.

The CellEndEdit event is always invoked on the thread which created the workbook view control, and a lock is always acquired on the workbook set associated with the workbook view control before CellEndEdit is invoked.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

Copyright © 2003-2010 SpreadsheetGear LLC. All Rights Reserved.Help Powered by Innovasys   
SpreadsheetGear is a registered trademark of SpreadsheetGear LLC.
Microsoft, Microsoft Excel and Visual Studio are trademarks or registered trademarks of Microsoft Corporation.