You really should try using Google or Yahoo or any other search engine.
However here is a step by step guide to setting up a context menu
http://www.c-sharpcorner.com/uploadfile/mahesh/context-menu-in-C-Sharp/[
^]
And to be on the safe side here is some information about RichTextBox
http://www.dotnetperls.com/richtextbox[
^]
[Edit]
Here is a (probably) better solution. On my form I have a RichTextBox (
richTextBox1
) into which I have placed some text. and a TextBox (
textBox1
) into which I have also typed some text. I highlight some text in richTextBox1 and use mouse-right-click to show the context menu. When I click on the menu it replaces the selected text with the words from the menu item.
private void DefineYourMenu()
{
ContextMenu Contextmenu1 = new ContextMenu();
MenuItem menuItem1 = new MenuItem(this.textBox1.Text);
menuItem1.Click += menuItem1_Click;
Contextmenu1.MenuItems.Add(menuItem1);
richTextBox1.ContextMenu = Contextmenu1;
}
private void menuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Text = richTextBox1.Text.Replace(richTextBox1.SelectedText.Trim(), ((MenuItem)sender).Text);
}
private void richTextBox1_Click(object sender, EventArgs e)
{
DefineYourMenu();
}