Click here to Skip to main content
12,446,418 members (57,708 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Handling RichTextBox
Hello ......
I wont to ask how to handle right click in richtextbox in c#......
for Example:
when i click on right click mouse over richtextbox the programe will display a messageBox.
Thanks A lot...
Posted 4-Aug-12 0:40am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
AbO_OsAmH 4-Aug-12 6:59am
   
it dose not contain how to handle right click >>>>
Sangramsingh Pawar 4-Aug-12 7:12am
   
why don't you use events?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

private void richTextBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         MessageBox.Show("you got it!");
     }
 
 }


This is the solution.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

void mousecontrol_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
{
FrameworkElement modeitem = e.OriginalSource as FrameworkElement;

ContextMenu modemenu = new ContextMenu();

clipboard_object = sender as System.Windows.Controls.ContentControl;
clipboard_status = false;
clipboard_type = clipboard_object.GetType();

modeitem.ContextMenu = modemenu;

MenuItem men1 = new MenuItem();
MenuItem men2 = new MenuItem();
MenuItem men3 = new MenuItem();
MenuItem men4 = new MenuItem();
MenuItem men5 = new MenuItem();
MenuItem men6 = new MenuItem();
MenuItem men7 = new MenuItem();
MenuItem men8 = new MenuItem();
MenuItem men9 = new MenuItem();
MenuItem men10 = new MenuItem();
MenuItem men11 = new MenuItem();
MenuItem men12 = new MenuItem();

men1.Header = "Cut";
men2.Header = "Copy";
men3.Header = "Paste";
men4.Header = "Delete";
men5.Header = "Protect";
men6.Header = "Delete Reference";
men7.Header = "Object Sequence";
men8.Header = "Visibility";
men9.Header = "Insert Interaction";
men10.Header = "Group";
men11.Header = "Align Object";
men12.Header = "Insert Text";

MenuItem men5_men1 = new MenuItem();
MenuItem men5_men2 = new MenuItem();
MenuItem men5_men3 = new MenuItem();
MenuItem men5_men4 = new MenuItem();

men5_men1.Header = "Presentation Mode";
men5_men2.Header = "Video Mode";
men5_men3.Header = "Practise Mode";
men5_men4.Header = "Assessment Mode";

men5_men1.IsChecked = true;
men5_men2.IsChecked = false;
men5_men3.IsChecked = true;
men5_men4.IsChecked = false;

// men1.Click += men1_Click;
// men2.Click += men2_Click;
// men3.Click += men3_Click;
// men4.Click += men4_Click;
modemenu.Items.Add(men1);
modemenu.Items.Add(men2);
modemenu.Items.Add(men3);
modemenu.Items.Add(men4);
modemenu.Items.Add(men5);
modemenu.Items.Add(men6);
modemenu.Items.Add(men7);
modemenu.Items.Add(men8);
modemenu.Items.Add(men9);
modemenu.Items.Add(men10);
modemenu.Items.Add(men11);
modemenu.Items.Add(men12);

men5.Items.Add(men5_men1);
men5.Items.Add(men5_men2);
men5.Items.Add(men5_men3);
men5.Items.Add(men5_men4);


}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 30 Sep 2015
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100