TX Text Control .NET for Windows Forms

Editing Text

Topic

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: Select and the Selection property, Copy, Paste, Undo, Find and 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 toRead
Select, read or replace text in code, or find out where the caret isSelections and Caret Position
Add Cut, Copy and Paste commands, or paste only plain textClipboard Operations
Show undo and redo in a menu, or undo several changes in one stepUndo and Redo
Open the Find and Replace dialog boxes, or replace text in codeSearch and Replace
Accept files dragged from File ExplorerDrag and Drop
Look up a key, or add shortcuts such as Ctrl+FKeyboard Shortcuts

Where to Start

  1. Read Selections and Caret Position first. The other pages select text and use text positions.
  2. Continue with the page of the command you want to add.
  3. Before you add a shortcut, check Keyboard Shortcuts for the keys the editor already uses.

Pages in This Section

Formatting the selected text is the subject of Text and Paragraph Formatting. To change documents without showing them, use Document Processing.