标签:
private static void InitRichTextBoxContextMenu(RichTextBox textBox)
{
//创建剪切子菜单
var cutMenuItem = new System.Windows.Forms.MenuItem("剪切");
cutMenuItem.Click += (sender, eventArgs) => textBox.Cut();
//创建复制子菜单
var copyMenuItem = new System.Windows.Forms.MenuItem("复制");
copyMenuItem.Click += (sender, eventArgs) => textBox.Copy();
//创建粘贴子菜单
var pasteMenuItem = new System.Windows.Forms.MenuItem("粘贴");
pasteMenuItem.Click += (sender, eventArgs) => textBox.Paste();
//创建右键菜单并将子菜单假日到右键菜单中
var contextMenu = new ContextMenu();
contextMenu.MenuItems.Add(cutMenuItem);
contextMenu.MenuItems.Add(copyMenuItem);
contextMenu.MenuItems.Add(pasteMenuItem);
textBox.ContextMenu = contextMenu;
}
标签:
原文地址:http://www.cnblogs.com/zhanglei93/p/4762037.html