[]
        
(Showing Draft Content)

Understanding Edit Mode in a Cell

Typically, when the end user double-clicks in the cell, the editor control is made available and the user can type in the cell. This ability to edit in a cell is called edit mode. Several properties and methods can customize the use of edit mode.

When the cell is in edit mode, the active cell typically displays a flashing I-beam cursor, as shown in the figure below. When the cell is not in edit mode, the active cell typically displays a focus rectangle, also as shown.

Cell in edit mode

Cell selected but not in edit mode

Spread WinForms screenshot illustrating Understanding Edit Mode in a Cell in a spreadsheet control, with the visible cells and interface state documenting the developer workflow.

Spread WinForms screenshot illustrating Understanding Edit Mode in a Cell in a spreadsheet control, with the visible cells and interface state documenting the developer workflow.

A cell enters edit mode (edit mode is turned on) when

  • the user starts typing in the cell

  • the user double-clicks the cell

  • the EditMode property is set to true

A cell leaves edit mode (edit mode is turned off) when

  • the user presses the Enter key

  • the user makes another cell the active cell

  • the application loses the focus

  • the EditMode property is set to false

When a cell enters edit mode, by default the cursor is positioned at the end of the existing text in the cell. You can change it to select the existing text in the cell by setting the EditModeReplace property.

If you prefer, you can specify that a cell is always in edit mode when it becomes the active cell using the EditModePermanent property.

When a cell enters edit mode, the EditModeOn event occurs; when a cell leaves edit mode, the EditModeOff event occurs.

You can set the position of the cursor in the edit control when it receives the focus by using the SuperEditBase.EditModeCursorPosition property.

You can start and stop edit mode by using the StartCellEditing and StopCellEditing methods.

You can keep the cell alignment when editing with the AllowEditorVerticalAlign property.

Customizing Arrow-Key Processing in the Editor

Use the AcceptsArrowKeys setting to specify how the text editor processes arrow keys when a cell is in edit mode. The setting also determines whether unhandled keys are passed to the parent control.

In single-byte character systems, a small text unit is a character, and a large text unit is a word. In double-byte character systems, both small and large text units are double-byte characters (glyphs).

Setting

Description

None

With this setting the text box does not process any of the arrow keys, and any arrow key pressed is passed to the parent control.

Arrows

With this setting the text box processes the keyboard arrow keys as long as the Ctrl key is not pressed. The left and right arrow keys move the cursor one small text unit left or right. If the text is on multiple lines, up and down arrow keys move the cursor up or down one line at a time. The combination of Ctrl key and any arrow key is passed to the parent control. If the text is not multiple line, up and down arrow keys are passed to the parent control.

CtrlArrows

With this setting the text box processes the keyboard arrow keys only when the Ctrl key is also pressed. The Ctrl-left and Ctrl-right arrow keys move the cursor one small text unit left or right. Ctrl-up and Ctrl-down arrow keys do nothing. Arrow keys without the Ctrl key are passed to the parent control. If the text is not on multiple lines, then Ctrl-up and Ctrl-down are passed to the parent control.

AllArrows

With this setting the text box processes all the keyboard arrow keys. This is essentially both Arrows and CtrlArrows combined. Both up and down as well as Ctrl-up and Ctrl-down key combinations are allowed. 

If text is on multiple lines:

  • Up and down arrow keys move the cursor one line at a time

  • Left and right arrow keys move the cursor one small text unit

  • Ctrl-up and Ctrl-down arrow keys do nothing

  • Ctrl-left and Ctrl-right arrow keys move the cursor by one large text unit

If text is not on multiple lines, up, down, Ctrl-up and Ctrl-down are passed to the parent control.

AllArrowsIgnoringMultiline

With this setting the text box the keyboard arrow keys similar to AllArrows with the added feature of allowing both up and down arrow keys and Ctrl-up and Ctrl-down arrow key combinations for both multiple lines and single lines.

If the text is on multiple lines, it is the same as for AllArrows.

If text is not on multiple lines,

  • Up and down arrow keys move left and right by one small text unit

  • Ctrl-up and Ctrl-down move the cursor left or right by one larger unit

This is the most inclusive setting and allows any arrow key (or Ctrl and arrow key combination) regardless of whether there are multiple lines (and the Multiline property setting in some cell types).

Using the Properties Window

  1. At design time, in the Properties window, select the Spread component.

  2. In the Properties window, select the EditModePermanent or EditModeReplace properties.

Using the Spread Designer

  1. Select the Settings menu.

  2. Select the Edit option (Spread Settings section).

  3. Check the Cells Always in EditMode option for EditModePermanent or Editing Replaces Existing Text for EditModeReplace.

  4. Use the File menu, then Apply and Exit to save the changes.

See Also

Locking a Cell