AllTheTimeWorld.com

csharp richtextUsing a context menu to copy, cut and paste.

Using a context menu to copy, cut and paste.

A context menu is a pop-up menu that appears on right click

Using a context menu to copy, cut and paste.

A context menu is a pop-up menu that appears on right click


Text of video

A Context menu (pop-up menu)

Although most IT professionals know to use Ctrl+V to paste, Ctrl+X to cut, and Ctrl+C to copy, there are many people who right click and then select copy, cut and paste from the context menu.

Add a context menu to the form and build the context menu as shown.

In the design mode, click on the richtextBox and select contextMenuStrip1 as the ContextMenuStrip.

Write the code as shown below:

private void contextCut_Click(object sender, EventArgs e)
{
   Cut();
}

private void contextCopy_Click(object sender, EventArgs e)
{
   Copy();
}

private void contextPaste_Click(object sender, EventArgs e)
{
   Paste();
}

To Do: Make sure this works before proceeding.