# Edit

## Content

When users edit a cell, the system supports two editing modes:

* **Input Mode**: Overwrites the existing cell content.
* **Edit Mode**: Appends or inserts content based on the existing content.

The editing mode of a cell depends on the user's operation, as described below:

| **<span class="resizer-hover-zone">Ways to Start Editing</span>** | **<span class="resizer-hover-zone">Cell State</span>** | **<span class="resizer-hover-zone">Arrow Key Handling</span>** |
| --------------------- | ---------- | ------------------ |
| <span class="resizer-hover-zone">Entering input via keyboard in the active cell</span> | <span class="resizer-hover-zone">"Input" (overwrite)</span> | <span class="resizer-hover-zone">Moves to another active cell</span> |
| <span class="resizer-hover-zone">Double-clicking the cell</span> | <span class="resizer-hover-zone">"Edit" (insert at mouse position)</span> | <span class="resizer-hover-zone">Moves the insertion point (cursor) within the cell</span> |
| <span class="resizer-hover-zone">Pressing the [F2] key</span> | <span class="resizer-hover-zone">"Edit" (append to the end)</span> | <span class="resizer-hover-zone">Moves the insertion point (cursor) within the cell</span> |

>type=note
> **Note**: Arrow keys refer to the up, down, left, and right arrow keys, as well as the [Home] and [End] keys.

## Disabling Cell Editing

You can disable users from editing cells using the following methods:

| **<span class="resizer-hover-zone">Method</span>** | **<span class="resizer-hover-zone">Description</span>** | **<span class="resizer-hover-zone">Setting Method</span>** |
| ------ | ----------- | -------------- |
| <span class="resizer-hover-zone">Locking the cell</span> | <span class="resizer-hover-zone">Users can select the cell but cannot edit it. When switching the active cell using [Enter], [Tab], or similar operations, the focus will move to these cells.</span> | <span class="resizer-hover-zone">Set the </span>[<span class="code" spellcheck="false" data-prosemirror-content-type="mark" data-prosemirror-mark-name="code">Locked</span>](/spreadnet/api/latest/online-wpf/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IRange.Locked.html)<span class="resizer-hover-zone"> property of the cell, row, or column.</span> |
| <span class="resizer-hover-zone">Set as read-only cell</span> | <span class="resizer-hover-zone">Users can select the cell and move the focus to the editor, partially select and copy the cell content, but cannot modify the content. When moving the active cell with keys such as [Enter] or [Tab], the focus will also move to these cells.</span> | <span class="resizer-hover-zone">Set the </span><span class="code" spellcheck="false" data-prosemirror-content-type="mark" data-prosemirror-mark-name="code">IsReadOnly</span><span class="resizer-hover-zone"> property to </span><span class="code" spellcheck="false" data-prosemirror-content-type="mark" data-prosemirror-mark-name="code">True</span><span class="resizer-hover-zone"> for editable cell types (such as standard, text, editable drop-down, date/time, mask, numeric, etc.).</span> |

## Edit and Events

When editing a cell, the control raises various events, such as the beginning and end of the editing process. This section explains the different events that are triggered during cell editing operations.

### Beginning Cell Edit

When a cell enters edit mode, [EditStarting](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.GcSpreadSheet.EditStarting.html) event is triggered by the control. 

### Completing Cell Edit

After editing is complete, [EditEnd](/spreadnet/api/latest/online-wpf/GrapeCity.Wpf.SpreadSheet/GrapeCity.Wpf.SpreadSheet.GcSpreadSheet.EditEnd.html) event is triggered by the control.

### Changing Cell Value

When the value of a cell changes, [CellValueChanged](/spreadnet/api/latest/online-wpf/GrapeCity.Spreadsheet/GrapeCity.Spreadsheet.IWorkbookSet.CellValueChanged.html) event is triggered to indicate that the cell’s value has been modified.

### Sample Code

The following code demonstrates how to display a message box when a cell finishes editing, either by pressing Enter or leaving the edit mode.

```csharp
private void GcSpreadSheet1_EditEnd(object sender, EventArgs e)
{
    MessageBox.Show("End of cell editing！");
}
```

```vbnet
Private Sub GcSpreadSheet1_EditEnd(sender As Object, e As EventArgs)
    MessageBox.Show("End of cell editing！")
End Sub
```