C # achieve a text editor clipboard functionality

4.2 to achieve a text editor clipboard functionality

Many programs support the clipboard function. Can be accomplished by clipping the data clipboard (Cut), copy (Copy), paste (Paste) functions.

Clipboard common region is to be understood that a data store, the user can cut and paste or copy data to the clipboard,
data present task or other tasks use the clipboard, the data can be removed from the clipboard with the paste.

Data stored in the clipboard, a single character, bit map, or other data formats.

Specific steps for implementing the functions editing and clipboard text editor as follows:

(1) New Project. Put RichTextBox control to the form. Attribute Name = richTextBox1, Dock = Fill, Text = "".

(2) put MenuStrip control to the form. Increase top-level menu items: Edit, its pop-up menu to add menu items:
cut, copy, paste, undo and redo, are property Name: mainMenuEdit, menuItemEditCut,
menuItemEditCopy, menuItemEditPaste, menuItemEditUndo, menuItemEditRedo. For the
handler following menu items increase event:

private void menuItemEditCut_Click(object sender, System.EventArgs e)
{ richTextBox1.Cut();} // 剪切
private void menuItemEditCopy_Click(object sender, System.EventArgs e)
{ richTextBox1.Copy();} // 拷贝
private void menuItemEditPaste_Click(object sender, System.EventArgs e)
{ richTextBox1.Paste();} // 粘贴
private void menuItemEditUndo_Click(object sender, System.EventArgs e)
{ richTextBox1.Undo();} // 撤销
private void menuItemEditRedo_Click(object sender, System.EventArgs e)
{ richTextBox1.Redo();} // 恢复

(3) compile, run, enter some characters, select some characters, try it cut, copy, paste and other functions, and to
look at whether the characters in the clipboard to paste into other word processing software, such as WordPad. Look revocation
and recovery feature is available.

Guess you like

Origin www.cnblogs.com/liudongjun/p/12214204.html