Zebra0.com

csharp richtext


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.

End of lesson, Next lesson: That is the last C# lesson in this course.