Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ask:copy,cut text with right click

mepalmepal Member Posts: 7
we highlight some texts in a richtextbox.and then we click right click and there will be appear some choices such as:copy,cut,paste etc.

can you help me to make the example of the program i mean?i mean just a simple program.

thanks

Comments

  • DaiMitnickDaiMitnick Member Posts: 77
    Best thing to do is add a context menu to the richtextbox (create a new contextmenu from the toolbox, then in the proerties window of the richtextbox choose the contextmenu in the contextmenustrip option). In the context menu create items you want, in my example I have just used cut, copy and paste. Then assign the code to the click event of each of these commands, luckily these particular ones are easy:


    Public Class Form1


    Private Sub ItemCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemCopy.Click
    RichTextBox1.Copy()
    End Sub

    Private Sub ItemCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemCut.Click
    RichTextBox1.Cut()
    End Sub

    Private Sub ItemPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemPaste.Click
    RichTextBox1.Paste()
    End Sub
    End Class
    ---------------------------------
    Do or do not, there is no try. |
    ---------------------------------
Sign In or Register to comment.