SpreadsheetGear 2012
CellBeginEdit Event (WorkbookView)
Example 






Occurs when edit mode is being initiated.
Syntax
'Declaration
 
<System.ComponentModel.CategoryAttribute("Data")>
<System.ComponentModel.DescriptionAttribute("Occurs when edit mode begins.")>
Public Event CellBeginEdit As CellBeginEditEventHandler
'Usage
 
Dim instance As WorkbookView
Dim handler As CellBeginEditEventHandler
 
AddHandler instance.CellBeginEdit, handler
[System.ComponentModel.Category("Data")]
[System.ComponentModel.Description("Occurs when edit mode begins.")]
public event CellBeginEditEventHandler CellBeginEdit
public event CellBeginEdit: CellBeginEditEventHandler; 
In JScript, you can handle the events defined by another class, but you cannot define your own.
[System.ComponentModel.Category("Data")]
[System.ComponentModel.Description("Occurs when edit mode begins.")]
public: __event CellBeginEditEventHandler* CellBeginEdit
[System.ComponentModel.Category("Data")]
[System.ComponentModel.Description("Occurs when edit mode begins.")]
public:
event CellBeginEditEventHandler^ CellBeginEdit
Event Data

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

PropertyDescription
CancelGets or sets the value which specifies whether the event should be canceled.  
EntryGets or sets the edit entry text.  
ReasonGets the reason for the event.  
Remarks

The CellBeginEdit event occurs when edit mode is being initiated, and provides the event handler with the ability to modify the text to be edited or cancel edit mode.

The CellBeginEdit 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 CellBeginEdit is invoked.

Example
/*
  * Sets the initial entry text to "Jim" when entry mode is initiated for cell B1.
  * 
  * Cancels entry mode for any cell other than B1.
  */
 private void workbookView_CellBeginEdit(object sender, CellBeginEditEventArgs e)
 {
     // Acquire a workbook set lock.
     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"]))
             // Change the entry text to "Jim".
             e.Entry = "Jim";
         else
             // Cancel CellBeginEdit.
             e.Cancel = true;
     }
     finally
     {
         // Release the workbook set lock.
         workbookView.ReleaseLock();
     }
 }
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

WorkbookView Class
WorkbookView Members

Send Feedback