Editing Text
Selecting, copying, undoing, finding and moving text are the everyday work of a word processor, and TextControl handles them for your users out of the box. The pages that follow cover what your Windows Forms application adds: reading and setting the selection and the caret, clipboard and undo commands in your own menus, searching and replacing in code, accepting dropped files and assigning keys.
How Editing Works in TextControl
- Built in. Typing, selecting with the mouse and the keyboard, the clipboard keys, undo and redo, and dragging selected text work as soon as the editor has the focus. No code is needed.
- In the ribbon. With the ribbon of Create Your First Windows Forms Application, the Home tab adds the Clipboard group and the Editing group with Find..., Replace..., Go to... and Select All.
- In code. The commands of the user have counterparts in the API:
Selectand theSelectionproperty,Copy,Paste,Undo,Findand more. Your code uses them for its own commands and to change documents at a known place.
Two terms run through all pages of this section. The input position is where typed text appears, marked by the caret. The selection is the highlighted range that the next command acts on. Both are counted in text positions, which start with 0 in front of the first character.
Find the Right Page
| If you want to | Read |
|---|---|
| Select, read or replace text in code, or find out where the caret is | Selections and Caret Position |
| Add Cut, Copy and Paste commands, or paste only plain text | Clipboard Operations |
| Show undo and redo in a menu, or undo several changes in one step | Undo and Redo |
| Open the Find and Replace dialog boxes, or replace text in code | Search and Replace |
| Accept files dragged from File Explorer | Drag and Drop |
| Look up a key, or add shortcuts such as Ctrl+F | Keyboard Shortcuts |
Where to Start
- Read Selections and Caret Position first. The other pages select text and use text positions.
- Continue with the page of the command you want to add.
- Before you add a shortcut, check Keyboard Shortcuts for the keys the editor already uses.
Pages in This Section
- Selections and Caret Position: text positions,
Select,Selection,InputPositionand the mouse actions. - Clipboard Operations:
Copy,Cut,Paste, clipboard formats and document permissions. - Undo and Redo: undo commands, action names, grouped steps and the undo buffer.
- Search and Replace: the Find and Replace dialog boxes and sidebars,
Findand replacing in all text parts. - Drag and Drop: moving text with the mouse, drop formats and dropped files.
- Keyboard Shortcuts: all built-in keys and your own shortcuts in
KeyDown.
Formatting the selected text is the subject of Text and Paragraph Formatting. To change documents without showing them, use Document Processing.