שתף באמצעות


how to turn on context menu in RIch Text Box?

Question

Friday, August 22, 2008 9:14 AM

how to turn on context menu in RIch Text Box?

for some reason textboxes have this as a default and you can easily copy, paste etc while rtb does not.


Cheers!

All replies (3)

Friday, August 22, 2008 10:28 AM ✅Answered

My bad.  I didn't take it through to runtime.  It must simply be part of the native control.

Something as simple as this:

  1. Add a ContextMenuStrip to your form.
    2) Add the following Menus on the strip: Cut, Copy, Paste
    3) Assign the Context Menu to the RichTextControl.
    4) Add the following code to the MenuItems:
    Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click  
        RichTextBox1.Cut()  
    End Sub 
 
    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click  
        RichTextBox1.Copy()  
    End Sub 
 
    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click  
        RichTextBox1.Paste()  
    End Sub 

Friday, August 22, 2008 9:46 AM

Select your RichTextBox in Design View.
Locate the property called ContextMenuStrip
Assign your MenuStrip.

I don't see a default context menu for textbox...so I am guessing you have one built that your textbox is pointing to.


Friday, August 22, 2008 10:02 AM

No i dont have my own. If you simply add text box to a form and right click on it in runtime the default windows context menu shows up - it's the same as Notepads - i wanted to know how could i get that one in rich text box control

Thank you for answer


Cheers!